Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] barrier destruction after wait() resultsin assertion
From: Peter Klotz (Peter.Klotz_at_[hidden])
Date: 2008-12-03 11:14:43


> > Anthony Williams:
> > ...
> >>> void f()
> >>> {
> >>> barrier->wait();
> >>> }
> >>>
> >>> int main(void)
> >>> {
> >>> barrier.reset(new boost::barrier(2));
> >>> boost::thread thread(boost::bind(&f));
> >>> barrier->wait();
> >>
> >> At this point, there is no guarantee that f() has started.
> >
> > Yes there is.
>
> Doh! Thanks Peter, apparently I'm not thinking straight today.
>
> Anyway, there is no guarantee that the call to wait in f() has
> *completed*, which means it might still own the mutex in barrier,
> which means it is not safe to destroy the barrier at this point.

Thanks for this clarification.

Regards, Peter.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net