How to structure a flow graph with a blocking input source

408 views Asked by At

What is a good way to modify Michael Voss' Feature Detection flow graph example when the source filter providing input images is blocking waiting for another image? This is a required modification if one wants to implement this graph for a continuous real-time input source like a video camera. I know that if the source filter function body is blocking waiting to pull an image from an input device, then one of the tbb threads will be wasted because it is idle.

I appreciate any guidance.

1

There are 1 answers

0
vinser52 On BEST ANSWER

There is async_node that is released in the TBB 4.3 Update 6 as a preview feature. The goal of this node is exactly fit for your needs. Here is the link to documentation https://www.threadingbuildingblocks.org/docs/help/reference/appendices/community_preview_features/flow_graph/async_node_cls.htm

You can create your own thread that will retrieve images from some source and using async_node::async_gateway push this messages to the graph. The advantage of such approach is that image retrieval will be done outside of TBB threads. This allows to execute other TBB tasks while your threads will wait for next image.