What sync object should i use?

Juan Manuel Cabo juanmanuel.cabo at gmail.com
Mon May 13 15:14:14 PDT 2013


On Monday, 13 May 2013 at 21:55:45 UTC, Steven Schveighoffer 
wrote:
> On Mon, 13 May 2013 17:04:22 -0400, Juan Manuel Cabo 
> <juanmanuel.cabo at gmail.com> wrote:
>
>> I seem to recall (though I might be wrong) that win32 events 
>> can be signalled before the thread calls WaitForSingleObject 
>> (or WaitForMultipleObjects), and if it was signalled, the call 
>> returns immediately. I think this was very useful.
>
> Right, the equivalent to a windows event is a D Mutex, 
> Condition, and a protected boolean.  In other words, the 
> condition aids synchronization of a message, but it is not the 
> message itself!  Windows events could serve as the message (but 
> not necessarily).
>
> -Steve

Thanks!!! Your explanation finally made it clear for me. It would 
be nice if this last paragraph of yours was in the documentation. 
It would save some headakes for people like me (I first viewed 
Condition as a drop in replacement of win32 events, didn't know 
of the pthreads way). And also, after reading the other link 
posted above:

    
http://stackoverflow.com/questions/2763714/why-do-pthreads-condition-variable-functions-require-a-mutex

I think I finally got it.

Thanks again!
--jm




More information about the Digitalmars-d-learn mailing list