Boost logo

Boost :

From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2005-09-12 00:59:49


Roland Schwarz schrieb:

<snip>
I found a small bug in my implementation. The --cv->waiters_ is unprotected.
Change this to to use InterlockedDecrement(&cv->waiters_) instead.

> switch(WaitForMultipleObjects(
> 2, cv->events_,FALSE,INFINITE)) {
> // on unblocking of the thread the gate is closed
> case WAIT_OBJECT_0+SIGNAL:
> InterlockedDecrement(&cv->waiters_); // one is leaving
> ReleaseSemaphore(cv->gate_,1,NULL);//reopen
> // no need to reset event, it is automatic
> break;
> case WAIT_OBJECT_0+BROADCAST:
> if (0 == IntelockedDecrement(&cv->waiters_)) {
> ResetEvent(
> cv->events_[BROADCAST]);
> // last leaving, reopen the gate
> ReleaseSemaphore(cv->gate_,1,NULL);
> }
> break;
> }
>
>
Regards,
Roland


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk