acl/app/wizard/tmpl/master/rpc_manager.cpp

37 lines
756 B
C++
Raw Normal View History

2014-11-19 00:25:21 +08:00
#include "stdafx.h"
#include "rpc_manager.h"
rpc_manager::rpc_manager()
: handle_(NULL)
{
}
rpc_manager::~rpc_manager()
{
delete service_;
if (handle_ != NULL)
handle_->check();
logger("rpc service destroy ok!");
}
2015-09-16 21:03:02 +08:00
void rpc_manager::init(acl::aio_handle& handle, int max_threads /* = 10 */,
2014-11-19 00:25:21 +08:00
const char* addr /* = NULL */)
{
2015-09-16 21:03:02 +08:00
handle_ = &handle;
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD><EFBFBD> rpc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
service_ = new acl::rpc_service(max_threads);
2015-09-16 21:03:02 +08:00
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
if (service_->open(handle_, addr && *addr ? addr : NULL) == false)
logger_fatal("open service error: %s", acl::last_serror());
else
2015-09-16 21:03:02 +08:00
logger("open service ok, listen: %s", service_->get_addr());
2014-11-19 00:25:21 +08:00
}
void rpc_manager::fork(acl::rpc_request* req)
{
service_->rpc_fork(req);
}