apache thrift C++ async client

心已入冬 提交于 2020-01-01 06:28:15

问题


I am looking for a C++ async client and nonblocking C++ server implementation. I see some mail archives in the apache but the activity is late in 2009. would like to know whether its supported in latest thrift or not. I am using the cob_style option for C++ code but the generated code does not compile. would appreciate any help, Thanks


回答1:


for a server, you have the TNonBlockingServer implementation in C++:

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();


来源:https://stackoverflow.com/questions/10344431/apache-thrift-c-async-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!