apache thrift C++ async client

前端 未结 1 1919
故里飘歌
故里飘歌 2021-01-03 07:45

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 wh

相关标签:
1条回答
  • 2021-01-03 08:29

    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();
    
    0 讨论(0)
提交回复
热议问题