public static RubyConditionVariable/*!*/ Broadcast(RubyConditionVariable/*!*/ self) {
RubyMutex m = self._mutex;
if (m != null) {
lock (self._lock) {
int waits = self._waits;
for (int i = 0; i < waits; i++) {
self._signal.Set();
//
// WARNING
//
// There is no guarantee that every call to the Set method will release a waiting thread.
// If two calls are too close together, so that the second call occurs before a thread
// has been released, only one thread is released.
// We add a sleep to increase the chance that all waiting threads will be released.
//
Thread.CurrentThread.Join(1);
}
}
}
return self;
}