internal void Exit(ref bool lockTaken)
 {
     try {
         MonitorUtils.Exit(this, ref lockTaken);
     } finally {
         if (!lockTaken)
         {
             _locked--;
         }
     }
 }
Esempio n. 2
0
        public static RubyMutex /*!*/ Unlock(RubyMutex /*!*/ self)
        {
            bool lockTaken = true;

            try {
                MonitorUtils.Exit(self._mutex, ref lockTaken);
            } finally {
                if (!lockTaken)
                {
                    self._isLocked = false;
                }
            }
            return(self);
        }
Esempio n. 3
0
        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;
                }
            }
        }