gpt4 book ai didi

thrift - apache thrift C++ 异步客户端

转载 作者:行者123 更新时间:2023-12-02 05:04:15 25 4
gpt4 key购买 nike

我正在寻找 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();

关于thrift - apache thrift C++ 异步客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10344431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com