コード例 #1
0
        public override void unlock(long id, functional.func ntf)
        {
            _strand.distribute(delegate()
            {
#if DEBUG
                Trace.Assert(id == _lockID);
#endif
                if (0 == --_recCount)
                {
                    if (0 != _waitQueue.Count)
                    {
                        _recCount            = 1;
                        wait_node queueFront = _waitQueue.First.Value;
                        _waitQueue.RemoveFirst();
                        _lockID = queueFront._id;
                        queueFront._ntf(chan_async_state.async_ok);
                    }
                    else
                    {
                        _lockID = 0;
                    }
                }
                ntf();
            });
        }
コード例 #2
0
 protected virtual void async_unlock_(long id, Action ntf)
 {
     Debug.Assert(id == _lockID);
     if (0 == --_recCount)
     {
         if (0 != _waitQueue.Count)
         {
             _recCount = 1;
             wait_node queueFront = _waitQueue.First.Value;
             _waitQueue.RemoveFirst();
             _lockID = queueFront._id;
             queueFront._ntf();
         }
         else
         {
             _lockID = 0;
         }
     }
     ntf();
 }
コード例 #3
0
 private void async_unlock_shared_(long id, Action ntf)
 {
     if (0 == --find_map(id)._count)
     {
         _sharedMap.Remove(id);
         if (0 == _sharedMap.Count && 0 != _waitQueue.Count)
         {
             _mustTick = true;
             wait_node queueFront = _waitQueue.First.Value;
             _waitQueue.RemoveFirst();
             queueFront._ntf();
             if (lock_status.st_shared == queueFront._status)
             {
                 base._lockID = 0;
                 find_map(queueFront._waitHostID)._count++;
                 for (LinkedListNode <wait_node> it = _waitQueue.First; null != it;)
                 {
                     if (lock_status.st_shared == it.Value._status)
                     {
                         find_map(it.Value._waitHostID)._count++;
                         it.Value._ntf();
                         LinkedListNode <wait_node> oit = it;
                         it = it.Next;
                         _waitQueue.Remove(oit);
                     }
                     else
                     {
                         it = it.Next;
                     }
                 }
             }
             else
             {
                 base._lockID = queueFront._waitHostID;
                 base._recCount++;
             }
             _mustTick = false;
         }
     }
     ntf();
 }