2019-07-27 22:44:32 +08:00
|
|
|
|
#include "stdafx.h"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include "rpc_manager.h"
|
|
|
|
|
|
|
|
|
|
rpc_manager::rpc_manager(int max_threads /* = 10 */)
|
|
|
|
|
{
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 因为本类实例是单例,会在程序 main 之前被调用,
|
|
|
|
|
// 所以需要在此类中打开日志
|
2014-11-19 00:25:21 +08:00
|
|
|
|
logger_open("gui_rpc.log", "gui_rpc");
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 创建非阻塞框架句柄,并采用 WIN32 消息模式:acl::ENGINE_WINMSG
|
2014-11-19 00:25:21 +08:00
|
|
|
|
handle_ = new acl::aio_handle(acl::ENGINE_WINMSG);
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 创建 rpc 服务对象
|
2014-11-19 00:25:21 +08:00
|
|
|
|
service_ = new acl::rpc_service(max_threads);
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 打开消息服务
|
2014-11-19 00:25:21 +08:00
|
|
|
|
if (service_->open(handle_) == false)
|
|
|
|
|
logger_fatal("open service error: %s", acl::last_serror());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rpc_manager::~rpc_manager()
|
|
|
|
|
{
|
|
|
|
|
delete service_;
|
|
|
|
|
handle_->check();
|
|
|
|
|
delete handle_;
|
|
|
|
|
logger("rpc service destroy ok!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void rpc_manager::fork(acl::rpc_request* req)
|
|
|
|
|
{
|
|
|
|
|
service_->rpc_fork(req);
|
|
|
|
|
}
|