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

How to catch exceptions sent by the pipeline?

jlabbesstl
Beginner
335 Views
Here is a simple example of what I would like to do :

m_pPipeline = new tbb::pipeline();
m_pPipeline->add_filter(*m_pElem1);
m_pPipeline->add_filter(*m_pElem2);

try{
m_pPipeline->run(2);
}
catch(EfromElem1& eElem1)
{
printf("Exception sent from the pipeline(Elem1)");
}
catch(EfromElem2& eElem2)
{
printf("Exception sent from the pipeline (Elem2)");
}

I can't find anything matching this kind of behaviour..
Is it possible? relevant? only in my dream?

Thanks for your answers.

Jeremie.
0 Kudos
2 Replies
RafSchietekat
Valued Contributor III
335 Views
Please first consult section "9 Exceptions" in "Reference (Open Source).pdf" revision 1.13 or later (possibly in the Commercial Documentation). If it doesn't contain the right information for you, please come back here with a more specific question.
0 Kudos
Alexey-Kukanov
Employee
335 Views
The code implies exact propagation of exceptions across threads; and this is not possible until C++0x.
TBB uses captured_exception and movable_exception classes to use with its parallel algorithms. The former is enough to transfer information about an std::exception and its derivatives, while the latter is useful to transfer some user-defined data.
In addition to the Reference manual, you might read a series of blogs written by Andrey Marochko.
0 Kudos
Reply