【问题标题】:apache thrift C++ async clientapache thrift C++ 异步客户端
【发布时间】:2012-04-29 18:35:32
【问题描述】:

我正在寻找 C++ 异步客户端和非阻塞 C++ 服务器实现。我在 apache 中看到了一些邮件档案,但活动是在 2009 年末。想知道它是否支持最新的 thrift。我对 C++ 代码使用 cob_style 选项,但生成的代码无法编译。 将不胜感激任何帮助, 谢谢

【问题讨论】:

    标签: thrift


    【解决方案1】:

    对于服务器,您有 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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-30
      • 2011-08-28
      • 2018-06-08
      • 2017-08-20
      • 2015-06-26
      • 2019-08-20
      • 2014-01-11
      • 1970-01-01
      相关资源
      最近更新 更多