Boost logo

Boost Users :

From: Sebastian Gesemann (s.gesemann_at_[hidden])
Date: 2008-01-31 10:15:15


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


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