/** * Unlink e */ private void unlink(Node x) { Node p = x.prev; Node n = x.next; if (p == null) { if (n == null) first = last = null; else { n.prev = null; first = n; } } else if (n == null) { p.next = null; last = p; } else { p.next = n; n.prev = p; } --count; notFull.signalAll(); }
/** * Unlink e */ private void unlink(Node x) { Node p = x.prev; Node n = x.next; if (p == null) { if (n == null) first = last = null; else { n.prev = null; first = n; } } else if (n == null) { p.next = null; last = p; } else { p.next = n; n.prev = p; } --count; notFull.signalAll(); }
/** * Unlink e */ private void unlink(Node x) { Node p = x.prev; Node n = x.next; if (p == null) { if (n == null) first = last = null; else { n.prev = null; first = n; } } else if (n == null) { p.next = null; last = p; } else { p.next = n; n.prev = p; } --count; notFull.signalAll(); }
public void onSignalAll() { lock.lock(); signalledThread = Thread.currentThread(); try { localCondition.signalAll(); } finally { lock.unlock(); } }
/** * Atomically removes all of the elements from this deque. * The deque will be empty after this call returns. */ public void clear() { lock.lock(); try { first = last = null; count = 0; notFull.signalAll(); } finally { lock.unlock(); } }
/** * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ public int drainTo(Collection c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); lock.lock(); try { for (Node p = first; p != null; p = p.next) c.add(p.item); int n = count; count = 0; first = last = null; notFull.signalAll(); return n; } finally { lock.unlock(); } }
/** * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ public int drainTo(Collection c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); lock.lock(); try { for (Node p = first; p != null; p = p.next) c.add(p.item); int n = count; count = 0; first = last = null; notFull.signalAll(); return n; } finally { lock.unlock(); } }
/** * Atomically removes all of the elements from this deque. * The deque will be empty after this call returns. */ public void clear() { lock.lock(); try { first = last = null; count = 0; notFull.signalAll(); } finally { lock.unlock(); } }
/** * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ public int drainTo(Collection c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); lock.lock(); try { for (Node p = first; p != null; p = p.next) c.add(p.item); int n = count; count = 0; first = last = null; notFull.signalAll(); return n; } finally { lock.unlock(); } }
/** * Atomically removes all of the elements from this deque. * The deque will be empty after this call returns. */ public void clear() { lock.lock(); try { first = last = null; count = 0; notFull.signalAll(); } finally { lock.unlock(); } }
/** * Performs common bookkeeping for poll and take: Replaces * first element with last; sifts it down, and signals any * waiting consumers. Call only when holding lock. * @param f the task to remove and return */ private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { int s = --size; RunnableScheduledFuture x = queue[s]; queue[s] = null; if (s != 0) { siftDown(0, x); available.signalAll(); } setIndex(f, -1); return f; }
/** * Performs common bookkeeping for poll and take: Replaces * first element with last; sifts it down, and signals any * waiting consumers. Call only when holding lock. * @param f the task to remove and return */ private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { int s = --size; RunnableScheduledFuture x = queue[s]; queue[s] = null; if (s != 0) { siftDown(0, x); available.signalAll(); } setIndex(f, -1); return f; }
/** * Performs common bookkeeping for poll and take: Replaces * first element with last; sifts it down, and signals any * waiting consumers. Call only when holding lock. * @param f the task to remove and return */ private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { int s = --size; RunnableScheduledFuture x = queue[s]; queue[s] = null; if (s != 0) { siftDown(0, x); available.signalAll(); } setIndex(f, -1); return f; }
public int drainTo(Collection c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); final ReentrantLock lock = this.lock; lock.lock(); try { int n = 0; for (;;) { RunnableScheduledFuture first = pollExpired(); if (first != null) { c.add(first); ++n; } else break; } if (n > 0) available.signalAll(); return n; } finally { lock.unlock(); } }
public int drainTo(Collection c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); final ReentrantLock lock = this.lock; lock.lock(); try { int n = 0; for (;;) { RunnableScheduledFuture first = pollExpired(); if (first != null) { c.add(first); ++n; } else break; } if (n > 0) available.signalAll(); return n; } finally { lock.unlock(); } }
private void deactivateDispatcher() { waitingExecutorLock.lock() ; try { dispatcherActive = false ; waitingDispatcherCondition.signal() ; waitingExecutorCondition.signalAll() ; } finally { waitingExecutorLock.unlock() ; } }
private void deactivateDispatcher() { waitingExecutorLock.lock() ; try { dispatcherActive = false ; waitingDispatcherCondition.signal() ; waitingExecutorCondition.signalAll() ; } finally { waitingExecutorLock.unlock() ; } }
/** * Atomically removes all of the elements from this queue. * The queue will be empty after this call returns. */ public void clear() { final Object[] items = this.items; final ReentrantLock lock = this.lock; lock.lock(); try { int i = takeIndex; int k = count; while (k-- > 0) { items[i] = null; i = inc(i); } count = 0; putIndex = 0; takeIndex = 0; notFull.signalAll(); } finally { lock.unlock(); } }
/** * Atomically removes all of the elements from this queue. * The queue will be empty after this call returns. */ public void clear() { final Object[] items = this.items; final ReentrantLock lock = this.lock; lock.lock(); try { int i = takeIndex; int k = count; while (k-- > 0) { items[i] = null; i = inc(i); } count = 0; putIndex = 0; takeIndex = 0; notFull.signalAll(); } finally { lock.unlock(); } }
/** * Atomically removes all of the elements from this queue. * The queue will be empty after this call returns. */ public void clear() { final Object[] items = this.items; final ReentrantLock lock = this.lock; lock.lock(); try { int i = takeIndex; int k = count; while (k-- > 0) { items[i] = null; i = inc(i); } count = 0; putIndex = 0; takeIndex = 0; notFull.signalAll(); } finally { lock.unlock(); } }