Boost logo

Boost :

Subject: Re: [boost] [thread] countdown_latch
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2013-05-15 13:10:48

On 14/05/2013 22.11, Michael Marcin wrote:
> On 5/14/13 2:21 PM, Gaetano Mendola wrote:
>> Given it has a clearly inspiration on Java one I would leave it like it
>> it now with the excpetion to permit count_down even if the counter is
>> zero already.
> I've seen that the Java one supports that, but most c++ implementations
> seem to not.
> What is the purpose of allowing count_down when the counter is already
> zero? What useful functionality does it enable?

It will permit a thread T1 to proceed if another thread T2 have executed
a certain operation at least N times, as it is implemented now
(with the precondition of count_down that counter > 0) T2 has to track
how many count_down it has executed (knowing then the initial value) or
issue a "try_wait" before the count_down and this IMHO seems a bit
Rubbing salt to the wound imagine if T1 has to wait that T2 and T3
have done a certain operation N times (in total), that way
T2 and T3 have to sync at start and communicate each other how many
count_down they have executed, the trick of issuing a "try_wait" in
this case doesn't work.

Gaetano Mendola

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