在 c++ 中处理复合异步函数
我有一个 API,它以异步方式从服务器发送/接收请求/数据。该API带有请求函数及其相应的回调。
我打算使用此 API,但应用程序中的单个函数可以在开始自行执行任何操作之前向服务器发送多个异步请求。是否有任何框架来管理复合异步函数。
一个例子是
void doSomething()
{
sendRequestDataItem1(); //receives result in getDataItem1()
sendRequestDataItem2(); //receives result in getDataItem2()
sendRequestDataItem3(); //receives result in getDataItem3()
//this function can either be a composite handler or something else
NowDoSomethingMore();
}
谢谢
西夫
I have an API which sends/receives request/data from the serve in an asynchronous manner. The API comes with request functions and their corresponding callbacks.
I intend to use this API but a single function in my application can send multiple asynchronous requests to the server before it starts doing anything on its own. Is there any framework to manage composite asynchronous functions.
An example would be
void doSomething()
{
sendRequestDataItem1(); //receives result in getDataItem1()
sendRequestDataItem2(); //receives result in getDataItem2()
sendRequestDataItem3(); //receives result in getDataItem3()
//this function can either be a composite handler or something else
NowDoSomethingMore();
}
Thanks
Shiv
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我推荐
boost::signals
,它非常容易使用。如果您需要线程安全(猜测?)boost::siganals2 是一个很好的起点。
I would recommend
boost::signals
, it is pretty easy to use.If you need thread safety (guessing?) boost::siganals2 is a good place to start.