|
Boost : |
Subject: Re: [boost] [thread] thread::join() + thread::interrupt() not reliable?
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2013-01-14 04:51:39
2013/1/14 Oliver Kowalke <oliver.kowalke_at_[hidden]>
>
> void fn1( boost::barrier * b)
> {
> b->wait();
> boost::this_thread::interruption_point();
> }
>
> void fn2( boost::thread * t1, boost::barrier * b, bool * interrupted)
> {
> t1->interrupt();
> b->wait();
> try
> { t1->join(); }
> catch ( boost::thread_interrupted const&)
> { * interrupted = true; }
> }
>
some correction -> replace
void fn1( boost::barrier * b)
{
b->wait();
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 1; //1 second
boost::this_thread::sleep( xt);
boost::this_thread::interruption_point();
}
void fn2( boost::thread * t1, boost::barrier * b, bool * interrupted)
{
b->wait();
t1->interrupt();
try
{ t1->join(); }
catch ( boost::thread_interrupted const&)
{ * interrupted = true; }
}
thread_interrupted is not catched
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk