apache thrift C++ async client

前端 未结 1 1926
故里飘歌
故里飘歌 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 handler(new MyHandler());
    shared_ptr processor(new (handler));
    shared_ptr protocolFactory(new TBinaryProtocolFactory());
    
    // using thread pool with maximum 15 threads to handle incoming requests
    shared_ptr threadManager = ThreadManager::newSimpleThreadManager(15);
    shared_ptr threadFactory = shared_ptr(new PosixThreadFactory());
    threadManager->threadFactory(threadFactory);
    threadManager->start();
    
    //create and start the server
    shared_ptr server = new  TNonblockingServer(processor, protocolFactory, port, threadManager);
    server->serve();
    

    0 讨论(0)
提交回复
热议问题