internal void Enter(ref bool lockTaken) { try { MonitorUtils.Enter(this, ref lockTaken); } finally { if (lockTaken) { _locked++; } } }
public static RubyMutex /*!*/ Lock(RubyMutex /*!*/ self) { bool lockTaken = false; try { MonitorUtils.Enter(self._mutex, ref lockTaken); } finally { if (lockTaken) { self._isLocked = true; } } 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; } } }
private static void SetCritical(RubyContext /*!*/ context, bool value) { Debug.Assert(context.RubyOptions.Compatibility < RubyCompatibility.Ruby19); if (value) { bool lockTaken = false; try { MonitorUtils.Enter(context.CriticalMonitor, ref lockTaken); } finally { // thread could have been aborted just before/after Monitor.Enter acquired the lock: if (lockTaken) { context.CriticalThread = Thread.CurrentThread; } } } else { Monitor.Exit(context.CriticalMonitor); context.CriticalThread = null; } }