1 Star 0 Fork 0

unitwork / iwechen-thrift

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ServerManager.h 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
wshy1121 提交于 2017-12-19 11:45 . mod 使用iwechen配置模块
#ifndef __SERVER_MANAGER_H__
#define __SERVER_MANAGER_H__
#include <string>
#include <vector>
#include <rapidjson/document.h>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
#include <thrift/server/TNonblockingServer.h>
typedef struct ServerHandle
{
boost::shared_ptr<::apache::thrift::server::TNonblockingServer> nonblockingServer;
boost::shared_ptr<boost::thread> serverThread;
}ServerHandle;
class CServerManager
{
public:
typedef boost::function<void(rapidjson::Document &, rapidjson::Value &)> Method;
CServerManager();
~CServerManager();
public:
static CServerManager* instance();
public:
bool StartServer();
bool thriftMethod(const std::string& method, rapidjson::Document &document, rapidjson::Value &returnValue);
bool RegisterMethod(const char *methodName, Method method);
private:
void ConnPoolInit(const rapidjson::Value &cfgValue);
private:
static CServerManager* _instance;
typedef std::map<std::string, Method> MethodMap;
MethodMap m_methodMap;
std::vector<boost::shared_ptr<ServerHandle>> m_serverHandleVector;
};
#endif
C++
1
https://gitee.com/unitwork/iwechen-thrift.git
git@gitee.com:unitwork/iwechen-thrift.git
unitwork
iwechen-thrift
iwechen-thrift
master

搜索帮助