apache thrift C++ 异步客户端 [英] apache thrift C++ async client

查看:55
本文介绍了apache thrift C++ 异步客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

对于服务器,您有 C++ 中的 TNonBlockingServer 实现:

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

这篇关于apache thrift C++ 异步客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆