From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-02-19 04:32:57
Matthew Vogt wrote:
> Michael Glassford <glassfordm <at> hotmail.com> writes:
>> How does it know when to release all the threads? Do you mean that you
>> would "register" ahead of time which threads are supposed to wait, and
>> it releases them all when they have all waited on the barrier? What
>> would happen if an "unregistered" thread tried to wait on the barrier?
> Yes, you could use the group for registration - have a set of threads
> which are all in the group, and each thread in the group blocks on the
> barrier unless it is the last thread of the the group to reach the
> barrier, in which case it releases all the other threads.
I think it's interesting idea.
> This would have to be a layer above pthread_barrier, I guess, and I don't
> the pthread barrier would actually be used to implement it... Is there
> any high performance- or correctness- oriented magic in the platform's
> barrier implementation?
> If a thread that was not part of the thread group waited on the barrier,
> you could either throw an exception, or simply allow it to also wait until
> the rest of the groups threads had entered.
> I'm not sure how this could be worked into the syntax, though...
What's even more interesting, it can be implemented as wrapper on top of
regular barrier: the 'wait' method would have to check that the waiting
thread in in group and throw if it's not.
Is it usefull? I don't know ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk