C ++ - Transferring data between threads

I have a thread pool consisting of 4 threads: t1, t2, t3 and t4. They work simultaneously, but the input from t3 and t4 depends on the output from t2. How should I implement a message queue so that after t2 completes, it sends the output to t3 and t4 for processing? I tried to implement a message queue using a blocking mechanism, but it seems that blocking is quite expensive. Is there a locking mechanism that transfers data between threads? I am using boost :: thread in visual studio 2010.

+5
source share
2 answers
+3
source

You may consider . It provides a wide range of parallel concepts, including concurrent_queue , concurrent_bounded_queue (for waiting), pipeline , flow::graph . The first two are also available in within MS VS 2010.

+1
source

Source: https://habr.com/ru/post/1207199/


All Articles