boost::asio::strand && boost::lockfree::spsc_queue

依然范特西╮ 提交于 2019-12-11 04:32:40

问题


If I am running a single an boost::asio::io_service with a thread pool and wrapping a particular socket receive using a boost::asio::strand to simulate single threaded operation, does anyone know if the strand meets the requirements to safely produce to a boost::lockfree::spsc_queue even though I will be producing from different threads but guaranteed to only produce one at a time.


回答1:


Yes. Serialization through a strand guarantees what you are after. To extend this a little bit, if you have multiple stands (for multiple sockets for example) - then no such guarantee exists across multiple strands pushing to the same queue.



来源:https://stackoverflow.com/questions/44182758/boostasiostrand-boostlockfreespsc-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!