Beispiel #1
0
            public object Run()
            {
                var transaction = _enclosing.CheckTransaction(trans);

                if (_enclosing._semaphores != null && transaction == _enclosing._semaphores
                    .Get(name))
                {
                    _enclosing._semaphores.Remove(name);
                }
                _enclosing._semaphoresLock.Awake();
                return(null);
            }
Beispiel #2
0
 public object Run()
 {
     try
     {
         var transaction          = _enclosing.CheckTransaction(trans);
         var candidateTransaction = _enclosing._semaphores.Get(name);
         if (trans == candidateTransaction)
         {
             acquired.value = true;
             return(null);
         }
         if (candidateTransaction == null)
         {
             _enclosing._semaphores.Put(name, transaction);
             acquired.value = true;
             return(null);
         }
         var  endtime  = Runtime.CurrentTimeMillis() + timeout;
         long waitTime = timeout;
         while (waitTime > 0)
         {
             _enclosing._semaphoresLock.Awake();
             _enclosing._semaphoresLock.Snooze(waitTime);
             if (_enclosing.ClassCollection() == null)
             {
                 acquired.value = false;
                 return(null);
             }
             candidateTransaction = _enclosing._semaphores.Get(name);
             if (candidateTransaction == null)
             {
                 _enclosing._semaphores.Put(name, transaction);
                 acquired.value = true;
                 return(null);
             }
             waitTime = endtime - Runtime.CurrentTimeMillis();
         }
         acquired.value = false;
         return(null);
     }
     finally
     {
         _enclosing._semaphoresLock.Awake();
     }
 }