线程安全的C / C ++队列推优化 [英] Thread-Safe C/C++ queue optimized for push
问题描述
我要寻找一个线程安全的C / C ++队列为按压操作优化的实现。我不介意弹出操作块,但我想永远不会被阻止上推一边。
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.
让我解释为什么。我计划写上探查了一个C#应用程序,我将有多个线程的消息推到一个调度线程。我不若调度块不久介意,但我想,以避免推侧面的任何延迟。
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.
推荐答案
您可以使用的 boost.lockfree 。它在推动沙箱SVN和计划与升压发布了1.53版本或1.54取决于是否不及时boost.atomic得到释放。
眼下boost.lockfree依赖的std ::原子而不是boost.atomic,所以你需要一个C ++编译器11来使用它。
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.
这篇关于线程安全的C / C ++队列推优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!