Subj : Re: win32 threads broken (was Win32 condition variables redux) To : comp.programming.threads From : d|dq Date : Wed Aug 03 2005 09:36 am Joe, Thanks for jumping in. I appreciate your insight. You seem to say (even) "CV redux" can't be programmed easily using Win32 primitives. Implementations I have seen rely on: - one or more critical sections - one or more semaphores - up to half a dozen counters - a data structure such as a queue or a doubly-linked linked list - a few Interlocked* this or Interlocked* that - up to a 1,000 lines of C code That's a lot of code to digest. In the end, it's very difficult to determine if problems are hidden in such complex implementations. (And I can't believe so much code and "logic" improves performance.) Example: The Apache Portable Runtime (APR) A Win32 implementation of condition variables has been part of APR for several years. People thought it worked. a few days ago, 2 patches had to be applied because it didn't work at all, even with 2 threads. That's just one example. There are many others. None of them give our industry a good name. But, going back to "CV redux"... Could it be done with: - 1 auto-reset event object (using WaitForSingleObject to wait and SetEvent to communicate a broadcast to all waiting threads by repeatedly marking the event signaled) - 1 "broadcast" flag - 1 "waiting" counter ? PS: According to several Microsoft employees, PulseEvent should be avoided like the plague. I even read that it remains in the Win32 API for backward compatibility reasons only. .