简体   繁体   English

Boost Asio-异步堆栈+轮询

[英]Boost Asio - async stack + poll

My application have a queue in a shared memory which is fed by another process. 我的应用程序在共享内存中有一个队列,该队列由另一个进程提供。 My main thread is looping over io_service.poll() to detect incoming event (mainly socket ones), and I would like to be notified through io_service.poll() when something is pushed into this queue. 我的主线程在io_service.poll()上循环以检测传入事件(主要是套接字事件),当将某些内容推送到此队列时,我想通过io_service.poll()进行通知。

Before migrating to boost.asio, I used to use the following mechanism: - extra thread polling onto the queue. 在迁移到boost.asio之前,我曾经使用以下机制:-对队列进行额外的线程轮询。 - on new element, I write into a pipe to notify main thread. -在新元素上,我写入管道以通知主线程。 - main thread is looping over a select. -主线程遍历选择。 On new element, pipe wakes up the select and I unstack my queue in a callback. 在新元素上,管道将唤醒选择,然后将我的队列堆积在回调中。

Is there more elegant ways to achieve similar behavior using boost.asio? 有没有更优雅的方法可以使用boost.asio实现类似的行为?

On windows, you will probably be able to use the Windows Object Handle service 在Windows上,您可能可以使用Windows对象句柄服务

Other than that I've seen some samples on integrating user-defined services here 除此之外,我还看到了一些在此处集成用户定义服务的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM