joyent/libuv — pull request #567 by hnakamur (2012-09-30 23:29:00+00:00)
Title: Condition variable support

This condition variable implementation is based on the SetEvent solution (section 3.2) at
http://www.cs.wustl.edu/~schmidt/win32-cv-1.html

I also implemented the SignalObjectAndWait solution (section 3.4) at
https://github.com/hnakamur/libuv/commits/cond_vars-SignalObjectAndWait/
Note: this implementation needs that uv_mutex_t implementation to be changed from
CRITICAL_SECTIONs to HANDLEs and APIs such as CreateMutex.
So there is a risk that cause incompatible behavior changes.

Here is a quote from "5. Concluding Remarks" from the above url.
> The SignalObjectsAndWait solution in Section 3.4 is a good approach if fairness is paramount. However, this approach is not as efficient as other solutions, nor is it as portable. Therefore, if efficiency or portability are more important than fairness, the SetEvent approach described in Section 3.2 may be more suitable. Naturally, the easiest solution would be for Microsoft to simply provide condition variables in the Win32 API.

Also my implementation using native CONDITION_VARIABLE is at
https://github.com/hnakamur/libuv/commits/cond_vars/

Preferably, we'd like to use CONDITION_VARIABLE when available, I don't know how to switch implementations, though. Maybe two different binaries for pre-Vista and post-Vista?
Or can we switch two implementations at runtime?

Could you review this pull request? I'd like to get some feedback on this.