- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to use a tbb::flow::async_node to execute a function in a dedicated thread. I have a tbb::flow::sequencer_node sending messages (in order) to an async_node but the async_node lambda function gets called in no specific order! There does not seem to be a way to specify that the async node is tbb::flow::serial. So the submit call to the async activity is not sequential...
Is there a way to make an async_node submitting its messages in a tbb::flow::serial fashion ?
Thanks !
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marc,
Yes, serial semantics for async_node is a missing feature, and it will be added in the future.
A possible workaround is to put a limiter_node with the limit of 1 in front of the async_node. The async_node functor should then explicitly decrement the limiter after sending the data to an external thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This may take a little bit of fitness...
Instead of sending a functor to the async_node, send the functor into a container that contains a ring buffer of functors and is managed in a MPSC manner. On first fill condition the PushNext function (called by the producer thread) enueues the (only) ring buffer container (the this of the container) to the asynchronous task. In this manner, there is only one ring buffer and all entries go into and come out in order.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you Alexey Kukanov and Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page