Thread-Safe C/C++ queue optimized for push

匆匆过客 提交于 2019-12-10 14:54:00

问题


I am looking for a thread-safe C/C++ queue implementation that is optimized for the push operation. I don't mind if the pop operation blocks but I would like to never be blocking on the push side.

Let me explain why. I am planning on writing a profiler for a C# application and I will have multiple threads pushing messages onto a single dispatcher thread. I don't mind if the dispatcher blocks shortly, but I would like to avoid any delay on the push side.


回答1:


You can use boost.lockfree. It's in boost sandbox svn and planned to be released with boost for version 1.53 or 1.54 depending on whether or not boost.atomic get released in time. For the moment boost.lockfree depends on std::atomic and not boost.atomic, so you need a c+11 compiler to use it.



来源:https://stackoverflow.com/questions/13561106/thread-safe-c-c-queue-optimized-for-push

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