Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 511
taylorjonl Avatar asked Oct 23 '22 00:10

taylorjonl


1 Answers

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.

like image 59
geekpp Avatar answered Nov 04 '22 20:11

geekpp