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); }
public static RubyConditionVariable /*!*/ Signal(RubyConditionVariable /*!*/ self) { RubyMutex m = self._mutex; if (m != null) { self._signal.Set(); } return(self); }
public static RubyConditionVariable /*!*/ Broadcast(RubyConditionVariable /*!*/ self) { RubyMutex m = self._mutex; if (m != null) { Monitor.PulseAll(m); } return(self); }
public static RubyConditionVariable /*!*/ Signal(RubyConditionVariable /*!*/ self) { RubyMutex m = self._mutex; if (m != null) { Monitor.Pulse(m); } return(self); }
public static bool TryLock(RubyMutex/*!*/ self) { bool lockTaken = false; try { MonitorUtils.TryEnter(self._mutex, ref lockTaken); } finally { if (lockTaken) { self._isLocked = true; } } return lockTaken; }
public static RubyMutex/*!*/ Unlock(RubyMutex/*!*/ self) { bool lockTaken = true; try { MonitorUtils.Exit(self._mutex, ref lockTaken); } finally { if (!lockTaken) { self._isLocked = false; } } return self; }
public static RubyConditionVariable /*!*/ Wait(RubyConditionVariable /*!*/ self, [NotNull] RubyMutex /*!*/ mutex) { self._mutex = mutex; RubyMutex.Unlock(mutex); lock (self._lock) { self._waits++; } self._signal.WaitOne(); lock (self._lock) { self._waits--; } RubyMutex.Lock(mutex); return(self); }
public static object Synchronize(BlockParam criticalSection, RubyMutex/*!*/ self) { lock (self._mutex) { self._isLocked = true; try { object result; criticalSection.Yield(out result); return result; } finally { self._isLocked = false; } } }
public static object Synchronize(BlockParam criticalSection, RubyMutex /*!*/ self) { lock (self._mutex) { self._isLocked = true; try { object result; criticalSection.Yield(out result); return(result); } finally { self._isLocked = false; } } }
public static bool TryLock(RubyMutex /*!*/ self) { bool lockTaken = false; try { MonitorUtils.TryEnter(self._mutex, ref lockTaken); } finally { if (lockTaken) { self._isLocked = true; } } return(lockTaken); }
public static RubyMutex /*!*/ Unlock(RubyMutex /*!*/ self) { bool lockTaken = true; try { MonitorUtils.Exit(self._mutex, ref lockTaken); } finally { if (!lockTaken) { self._isLocked = false; } } return(self); }
public static object Synchronize(BlockParam criticalSection, RubyMutex/*!*/ self) { bool lockTaken = false; try { MonitorUtils.Enter(self._mutex, ref lockTaken); self._isLocked = lockTaken; object result; criticalSection.Yield(out result); return result; } finally { if (lockTaken) { MonitorUtils.Exit(self._mutex, ref lockTaken); self._isLocked = lockTaken; } } }
public static object Synchronize(BlockParam criticalSection, RubyMutex /*!*/ self) { bool lockTaken = false; try { MonitorUtils.Enter(self._mutex, ref lockTaken); self._isLocked = lockTaken; object result; criticalSection.Yield(out result); return(result); } finally { if (lockTaken) { MonitorUtils.Exit(self._mutex, ref lockTaken); self._isLocked = lockTaken; } } }
public static bool TryLock(RubyMutex /*!*/ self) { return(self._isLocked = Monitor.TryEnter(self._mutex)); }
public static bool ExclusiveUnlock(BlockParam criticalSection, RubyMutex/*!*/ self) { // TODO: throw new NotImplementedException(); }
public static RubyMutex/*!*/ Lock(RubyMutex/*!*/ self) { Monitor.Enter(self._mutex); self._isLocked = true; return self; }
public static RubyMutex/*!*/ Unlock(RubyMutex/*!*/ self) { self._isLocked = false; Monitor.Exit(self._mutex); return self; }
public static bool IsLocked(RubyMutex/*!*/ self) { return self._isLocked; }
public static bool TryLock(RubyMutex/*!*/ self) { return self._isLocked = Monitor.TryEnter(self._mutex); }
public static RubyMutex /*!*/ Lock(RubyMutex /*!*/ self) { Monitor.Enter(self._mutex); self._isLocked = true; return(self); }
public static RubyConditionVariable /*!*/ Wait(RubyConditionVariable /*!*/ self, [NotNull] RubyMutex /*!*/ mutex) { self._mutex = mutex; Monitor.Wait(mutex.Mutex); return(self); }
public static RubyMutex /*!*/ Unlock(RubyMutex /*!*/ self) { self._isLocked = false; Monitor.Exit(self._mutex); return(self); }
public static bool IsLocked(RubyMutex /*!*/ self) { return(self._isLocked); }
public static bool ExclusiveUnlock(BlockParam criticalSection, RubyMutex /*!*/ self) { // TODO: throw new NotImplementedException(); }