예제 #1
0
 internal void Exit(ref bool lockTaken)
 {
     try {
         MonitorUtils.Exit(this, ref lockTaken);
     } finally {
         if (!lockTaken)
         {
             _locked--;
         }
     }
 }
예제 #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);
        }
예제 #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;
                }
            }
        }