|
Boost Users : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2008-01-31 09:37:21
Kesseli Pascal wrote:
> Hey Ya
>
> Thanks for the quick reply. Well, it would be more complicated in the way
> that the only condition that would keep in the loop would be the number of
> threads already arrived on this condition (numberOfThreadsReady). As soon
> as all threads have arrived, this number is set back to zero, which would
> keep the threads waiting if they re-checked this condition.
>
> But I found out that Boost supports a much more suitable solution for this
> problem, namely the barrier class.
Right, and it's a bit trickier -- there's something called 'generation number'
which is incremented when all thread arrive -- and the wait is actually on
generation number change, so resetting of thread count is not a problem.
> And, concerning the use of a barrier, I
> trust I am not mistaken that there is no loop needed when calling
> barrier.wait(), or is there :) ?
There is no need to wrap barrier.wait() in a loop.
- Volodya
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