The wait node used by implementations of IWaitQueue. NOTE: this class is NOT present in java.util.concurrent.
コード例 #1
0
 public void Enqueue(WaitNode w)
 {
     if (_tail == null)
     {
         _head = _tail = w;
     }
     else
     {
         _tail.NextWaitNode = w;
         _tail = w;
     }
 }
コード例 #2
0
        public WaitNode Dequeue()
        {
            if (_head == null)
            {
                return(null);
            }

            var w = _head;

            _head = w.NextWaitNode;
            if (_head == null)
            {
                _tail = null;
            }
            w.NextWaitNode = null;
            return(w);
        }
コード例 #3
0
 public void Enqueue(WaitNode w)
 {
     if (_tail == null)
         _head = _tail = w;
     else
     {
         _tail.NextWaitNode = w;
         _tail = w;
     }
 }
コード例 #4
0
        public WaitNode Dequeue()
        {
            if (_head == null) return null;

            var w = _head;
            _head = w.NextWaitNode;
            if (_head == null) _tail = null;
            w.NextWaitNode = null;
            return w;
        }
コード例 #5
0
 public void TakeOver(WaitNode node)
 {
 }
コード例 #6
0
 public bool Recheck(WaitNode node)
 {
     return false;
 }
コード例 #7
0
 private void DoWait(Action<WaitNode> action)
 {
     var holdCount = Lock.HoldCount;
     if (holdCount == 0)
     {
         throw new SynchronizationLockException();
     }
     var n = new WaitNode();
     _wq.Enqueue(n);
     for (var i = holdCount; i > 0; i--) Lock.Unlock();
     try
     {
         action(n);
     }
     finally
     {
         for (var i = holdCount; i > 0; i--) Lock.Lock();
     }
 }
コード例 #8
0
 public override bool TryLock(TimeSpan timespan)
 {
     var caller = Thread.CurrentThread;
     lock (this)
     {
         if (GetHold(caller)) return true;
     }
     var n = new WaitNode();
     return n.DoTimedWait(this, timespan);
 }
コード例 #9
0
 public void TakeOver(WaitNode node)
 {
     lock (this)
     {
         Debug.Assert(_holds == 1 && _owner == Thread.CurrentThread);
         _owner = node.Owner;
     }
 }
コード例 #10
0
 public bool Recheck(WaitNode node)
 {
     var caller = Thread.CurrentThread;
     lock (this)
     {
         if (GetHold(caller)) return true;
         _wq.Enqueue(node);
         return false;
     }
 }
コード例 #11
0
 public override void LockInterruptibly()
 {
     var caller = Thread.CurrentThread;
     lock (this)
     {
         if (GetHold(caller)) return;
     }
     var n = new WaitNode();
     n.DoWait(this);
 }