/// <summary> /// 结束运行 依次唤醒等待get结果的节点 /// </summary> private void finishCompletion() { // assert state > COMPLETING; for (WaitNode q; (q = waiters) != null;) { if (Interlocked.CompareExchange <WaitNode>(ref waiters, null, q) == q) { for (; ;) { Thread t = q.thread; if (t != null) { q.thread = null; LockSupport.unpark(t); } WaitNode next = q.next; if (next == null) { break; } q.next = null; // unlink to help gc q = next; } break; } } done(); callable = null; // to reduce footprint }
private int Poke() { int result = this._targetTicket.incrementAndGet(); LockSupport.unpark(_updatePullingThread); return(result); }
public override void Run() { while (!_closed) { if (_hasReadAhead || _eof) { // We have already read ahead, sleep a little ParkAWhile(); } else { // We haven't read ahead, or the data we read ahead have been consumed try { if (!ReadAhead()) { _eof = true; } _hasReadAhead = true; LockSupport.unpark(_owner); } catch (IOException e) { _ioException = e; _closed = true; } catch (Exception e) { _ioException = new IOException(e); _closed = true; } } } }
/// <summary> /// 唤醒下一个等待线程 /// </summary> /// <param name="node"></param> private void UnparkSuccessor(Node node) { int ws = node.WaitStatus; if (ws < 0) { CompareAndSetWaitStatus(node, ws, 0); } Node s = node.Next; //节点为null或者已经取消 则寻找下一个节点 if (s == null || s.WaitStatus > 0) { s = null; //从后向前找最前面可以被唤醒的节点 不知道为什么不从前往后找 for (Node t = Tail; t != null && t != node; t = t.Prev) { if (t.WaitStatus <= 0) { s = t; } } } //唤醒该节点线程 if (s != null) { LockSupport.unpark(s.Thread); } }
private void UnparkEvictor() { if (_evictorParked) { _evictorParked = false; LockSupport.unpark(_evictionThread); } }
private void UnparkSuccessor(Node waiters) { if (waiters.GetType() == typeof(Waiter)) { Waiter waiter = ( Waiter )waiters; waiter.State = WAITER_STATE_SUCCESSOR; LockSupport.unpark(waiter.WaitingThread); } }
public override void Stop() // for removing throw declaration { if (_shutdownLatch == null) { return; // This SlaveUpdatePuller has already been shut down } Thread thread = _updatePullingThread; _halted = true; LockSupport.unpark(thread); _shutdownLatch.await(); _shutdownLatch = null; }
public override void Send(T @event) { AsyncEvent prev = _stackUpdater.getAndSet(this, @event); Debug.Assert(prev != null); @event.Next = prev; if (prev == _endSentinel) { LockSupport.unpark(_backgroundThread); } else if (prev == _shutdownSentinel) { AsyncEvent events = _stackUpdater.getAndSet(this, _shutdownSentinel); Process(events); } }
private void UnparkAll(Node waiters) { // If we find a node that is not a waiter, then it is either 'end' or 'released'. Looking at the type pointer // is the cheapest way to make this check. while (waiters.GetType() == typeof(Waiter)) { Waiter waiter = ( Waiter )waiters; waiter.State = WAITER_STATE_RELEASED; LockSupport.unpark(waiter.WaitingThread); Node next; do { // Just like in isReleased, loop if the next pointer is null. next = waiters.Next; } while (next == null); waiters = next; } }
public void shutdown() { _isRunnable = false; LockSupport.unpark(_timerThread); try { long sleepTime = 200; if (CurrentTime.isTest()) { sleepTime = 1; } Thread.sleep(sleepTime); } catch (Exception e) { } }
/// <summary> /// Initiate the shut down process of this {@code AsyncEvents} instance. /// <para> /// This call does not block or otherwise wait for the background thread to terminate. /// </para> /// </summary> public virtual void Shutdown() { Debug.Assert(!_shutdown, "Already shut down"); _shutdown = true; LockSupport.unpark(_backgroundThread); }
internal void EnqueueTask(ScheduledJobHandle newTasks) { _delayedTasks.offer(newTasks); LockSupport.unpark(_timeKeeper); }
public void Stop() { _stopped = true; LockSupport.unpark(_timeKeeper); }
internal virtual void Unpark() { LockSupport.unpark(Owner); }
public virtual void signal() { LockSupport.unpark(consumer); }
public override void Unpark(Thread thread) { LockSupport.unpark(thread); }
public virtual void Unpark() { LockSupport.unpark(Thread); }
protected internal virtual void PokeReader() { // wake up the reader... there's stuff to do, data to read _hasReadAhead = false; LockSupport.unpark(this); }