/** * Removes and returns first element, or null if empty. */ private Object unlinkFirst() { Node f = first; if (f == null) return null; Node n = f.next; first = n; if (n == null) last = null; else n.prev = null; --count; notFull.signal(); return f.item; }
private void deactivateDispatcher() { waitingExecutorLock.lock() ; try { dispatcherActive = false ; waitingDispatcherCondition.signal() ; waitingExecutorCondition.signalAll() ; } finally { waitingExecutorLock.unlock() ; } }
/** * Removes and returns last element, or null if empty. */ private Object unlinkLast() { Node l = last; if (l == null) return null; Node p = l.prev; last = p; if (p == null) first = null; else p.next = null; --count; notFull.signal(); return l.item; }
private void deactivateDispatcher() { waitingExecutorLock.lock() ; try { dispatcherActive = false ; waitingDispatcherCondition.signal() ; waitingExecutorCondition.signalAll() ; } finally { waitingExecutorLock.unlock() ; } }
/** * Removes and returns first element, or null if empty. */ private Object unlinkFirst() { Node f = first; if (f == null) return null; Node n = f.next; first = n; if (n == null) last = null; else n.prev = null; --count; notFull.signal(); return f.item; }
/** * Inserts element at current put position, advances, and signals. * Call only when holding lock. */ private void insert(Object x) { items[putIndex] = x; putIndex = inc(putIndex); ++count; notEmpty.signal(); }
/** * Inserts element at current put position, advances, and signals. * Call only when holding lock. */ private void insert(Object x) { items[putIndex] = x; putIndex = inc(putIndex); ++count; notEmpty.signal(); }
/** * Inserts element at current put position, advances, and signals. * Call only when holding lock. */ private void insert(Object x) { items[putIndex] = x; putIndex = inc(putIndex); ++count; notEmpty.signal(); }
/** * Extracts element at current take position, advances, and signals. * Call only when holding lock. */ private Object extract() { final Object[] items = this.items; Object x = items[takeIndex]; items[takeIndex] = null; takeIndex = inc(takeIndex); --count; notFull.signal(); return x; }
/** * Extracts element at current take position, advances, and signals. * Call only when holding lock. */ private Object extract() { final Object[] items = this.items; Object x = items[takeIndex]; items[takeIndex] = null; takeIndex = inc(takeIndex); --count; notFull.signal(); return x; }
/** * Extracts element at current take position, advances, and signals. * Call only when holding lock. */ private Object extract() { final Object[] items = this.items; Object x = items[takeIndex]; items[takeIndex] = null; takeIndex = inc(takeIndex); --count; notFull.signal(); return x; }
/** * Links e as first element, or returns false if full. */ private boolean linkFirst(Object e) { if (count >= capacity) return false; ++count; Node f = first; Node x = new Node(e, null, f); first = x; if (last == null) last = x; else f.prev = x; notEmpty.signal(); return true; }
/** * Links e as first element, or returns false if full. */ private boolean linkFirst(Object e) { if (count >= capacity) return false; ++count; Node f = first; Node x = new Node(e, null, f); first = x; if (last == null) last = x; else f.prev = x; notEmpty.signal(); return true; }
/** * Links e as last element, or returns false if full. */ private boolean linkLast(Object e) { if (count >= capacity) return false; ++count; Node l = last; Node x = new Node(e, l, null); last = x; if (first == null) first = x; else l.next = x; notEmpty.signal(); return true; }
/** * Links e as first element, or returns false if full. */ private boolean linkFirst(Object e) { if (count >= capacity) return false; ++count; Node f = first; Node x = new Node(e, null, f); first = x; if (last == null) last = x; else f.prev = x; notEmpty.signal(); return true; }
/** * Links e as last element, or returns false if full. */ private boolean linkLast(Object e) { if (count >= capacity) return false; ++count; Node l = last; Node x = new Node(e, l, null); last = x; if (first == null) first = x; else l.next = x; notEmpty.signal(); return true; }
public void onSignal() { lock.lock(); signalledThread = Thread.currentThread(); try { localCondition.signal(); } finally { lock.unlock(); } }
boolean submitJob(final Job job) { waitingExecutorLock.lock() ; try { if (hasFreeExecutor()) { dispatchedJobs.add(job) ; waitingExecutorCondition.signal() ; return true ; } } finally { waitingExecutorLock.unlock() ; } return false ; }
boolean submitJob(final Job job) { waitingExecutorLock.lock() ; try { if (hasFreeExecutor()) { dispatchedJobs.add(job) ; waitingExecutorCondition.signal() ; return true ; } } finally { waitingExecutorLock.unlock() ; } return false ; }
public Object take() throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { try { while (count == 0) notEmpty.await(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } Object x = extract(); return x; } finally { lock.unlock(); } }