Re: [Boost-users] Boost Thread: condition.wait()

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. 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 :) ? If so, that would call my complete understanding of the barrier mechanism into question :) . Thanks again & greeetz Pascal "Vladimir Prus" <ghost@cs.msu.su> schrieb im Newsbeitrag news:<fnp5p1$cce$1@ger.gmane.org>... section. thing
has similar behaviour).
- Volodya
No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.16/1251 - Release Date: 30.01.2008 09:29

Kesseli Pascal wrote:
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.
There is no need to wrap barrier.wait() in a loop. - Volodya

On Jan 31, 2008 3:16 PM, Kesseli Pascal wrote:
I also thought about recommending Barrier to you. The wait() function even returns a bool for exactly one calling thread so that it can merge the worker's results. The problem is however that the other worker threads start doing their thing while the "master" thread merges the results. So, you need "two barriers" (wait() invocations) per round to also synchronize the round's start. Since I think this is a common pattern one yould extend boost::barrier so that the last arriving thread executes a previously defined function _right before_ the other threads awake. Cheers! SG
participants (3)
-
Kesseli Pascal
-
Sebastian Gesemann
-
Vladimir Prus