Boost logo

Boost :

Subject: Re: [boost] [thread] countdown_latch
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2013-05-13 19:01:22

On 27/04/2013 09.05, Vicente J. Botet Escriba wrote:
> Le 22/04/13 10:16, Michael Marcin a écrit :
>> On 4/21/2013 11:30 PM, Vicente J. Botet Escriba wrote:
> Hi,
>> Back on topic of latches and barriers.
>> I was reading up on Java's CyclicBarrier and found its await return
>> value pretty interesting and probably fairly free to implement.
>> "...each invocation of await() returns the arrival index of that
>> thread at the barrier."
>> "the arrival index of the current thread, where index getParties() - 1
>> indicates the first to arrive and zero indicates the last to arrive."
>> To do this in boost::thread::barrier you would just have to cache
>> m_count right after the decrement and return it instead of the current
>> true/false.
> Yes, boost::barrier return true for the last wait. The change would be
> quite simple, but what would be he utility of such an index?
> I have implemented a first prototype of a latch class that could be used
> also as a barrier. I don't know if the name is the good one then.
> I have also implemented a completion_latch class that is able to call a
> function when the counter reaches zero. I'm not satisfied with the
> current implementation as it needs a lot of synchronization.
> The change set is To
> see the sources, you would need to update the trunk or to take a look at
> Please let me know what do you think.

Java implementation of CountDownLatch permits count_down to be called
multiple time even if the counter has reached 0, in that case nothing
will happen, in your implementation the count > 0 is a precondition,
I would implement has described by Java

Gaetano Mendola

Boost list run by bdawes at, gregod at, cpdaniel at, john at