我正在寻找 C++ 异步客户端和非阻塞 C++ 服务器实现。我在 apache 中看到一些邮件档案,但该活动是 2009 年末的。想知道最新的 thrift 是否支持它。我正在对 C++ 代码使用 cob_style 选项,但生成的代码无法编译。
将不胜感激任何帮助,
谢谢
对于服务器,您有 C++ 中的 TNonBlockingServer 实现:
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using namespace ::apache::thrift::concurrency;
shared_ptr<MyHandler> handler(new MyHandler());
shared_ptr<TProcessor> processor(new (handler));
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
// using thread pool with maximum 15 threads to handle incoming requests
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(15);
shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
//create and start the server
shared_ptr<TNonblockingServer> server = new TNonblockingServer(processor, protocolFactory, port, threadManager);
server->serve();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)