Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

how to structure a flow graph with a blocking input source

Philip_M_
Beginner
363 Views

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 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.

0 Kudos
3 Replies
Francis_R_1
Beginner
363 Views

I'm also interested in learning how to deal with blocking inputs.

0 Kudos
RafSchietekat
Valued Contributor III
363 Views

Couldn't you just let the Body return false to indicate that there are no more inputs, and then activate() the source_node as soon as new inputs are available again?

0 Kudos
Sergey_V_Intel
Employee
363 Views

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.

0 Kudos
Reply