
4 Mar
2009
4 Mar
'09
2:35 p.m.
Just a small addition. Instead of sleep, you can use a condition variable
and wait on it with timeout. So the if condition would be smth like:
if(!timed_wait(cond, timeout))
t1.interrupt();
On Wed, Mar 4, 2009 at 3:30 PM, Ovanes Markarian
Stephan,
what about that:
On Wed, Mar 4, 2009 at 3:20 PM, Stephan Menzel
wrote: like this (pseudo):
void readthread() { try
{
// go into blocking read sock.sync_receive_from(...);
// signal successful read } catch(boost::thread_interrupted const& e) { //handle interruption }
}
original thread:
... thread t1(readthread); boost::this_thread::sleep(timeout);
if(/*not signaled successful read*/) t1.interrupt();
Regards, Ovanes