On Jan 31, 2008 3:16 PM, Kesseli Pascal wrote:
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 :) ?
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