Can someone please show a simple, but complete example of how one could use Boost exception library to transfer exceptions between thread by modifying the code below?
What I'm implementing is a simple multi-threaded Delegate pattern.
class DelegeeThread
{
public:
void operator()()
{
while(true)
{
// Do some work
if( error )
{
// This exception must be caught by DelegatorThread
throw std::exception("An error happened!");
}
}
}
};
class DelegatorThread
{
public:
DelegatorThread() : delegeeThread(DelegeeThread()){} // launches DelegeeThread
void operator()()
{
while( true )
{
// Do some work and wait
// ? What do I put in here to catch the exception thrown by DelegeeThread ?
}
}
private:
tbb::tbb_thread delegeeThread;
};