I have a thread pool consists of 4 threads: t1, t2, t3, and t4. They are running concurrently, but the input from t3 and t4 depends on output from t2. How should I implement message queue so that after t2 completes, it will send the output data to t3 and t4 for processing? I have tried to implement the message queue using locking mechanism, but it seems that the locking is quite expensive. Is there lock-free mechanism that pass data between threads? I am using boost::thread in visual studio 2010.
Boost has a lock-free queue: http://www.boost.org/doc/libs/1_56_0/doc/html/lockfree.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With