/** * The calling thread MUST be the thread that uses the signal * @return x */ public Signal register() { RegisteredSignal signal = new RegisteredSignal(); queue.add(signal); return signal; }
@Override public boolean checkAndClear() { context.stop(); return super.checkAndClear(); }
private void cleanUpCancelled() { // TODO: attempt to remove the cancelled from the beginning only (need atomic cas of head) Iterator<RegisteredSignal> iter = queue.iterator(); while (iter.hasNext()) { RegisteredSignal s = iter.next(); if (s.isCancelled()) iter.remove(); } }
/** * Should only be called by the registered thread. Indicates the signal can be retired, * and if signalled propagates the signal to another waiting thread */ public void cancel() { if (isCancelled()) return; if (!signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { // must already be signalled - switch to cancelled and state = CANCELLED; // propagate the signal WaitQueue.this.signal(); } thread = null; cleanUpCancelled(); } }
/** * Should only be called by the registered thread. Indicates the signal can be retired, * and if signalled propagates the signal to another waiting thread */ public void cancel() { if (isCancelled()) return; if (!signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { // must already be signalled - switch to cancelled and state = CANCELLED; // propagate the signal WaitQueue.this.signal(); } thread = null; cleanUpCancelled(); } }
/** * Should only be called by the registered thread. Indicates the signal can be retired, * and if signalled propagates the signal to another waiting thread */ public void cancel() { if (isCancelled()) return; if (!signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { // must already be signalled - switch to cancelled and state = CANCELLED; // propagate the signal WaitQueue.this.signal(); } thread = null; cleanUpCancelled(); } }
/** * Should only be called by the registered thread. Indicates the signal can be retired, * and if signalled propagates the signal to another waiting thread */ public void cancel() { if (isCancelled()) return; if (!signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { // must already be signalled - switch to cancelled and state = CANCELLED; // propagate the signal WaitQueue.this.signal(); } thread = null; cleanUpCancelled(); } }
/** * Should only be called by the registered thread. Indicates the signal can be retired, * and if signalled propagates the signal to another waiting thread */ public void cancel() { if (isCancelled()) return; if (!signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { // must already be signalled - switch to cancelled and state = CANCELLED; // propagate the signal WaitQueue.this.signal(); } thread = null; cleanUpCancelled(); } }
private Thread signal() { if (!isSet() && signalledUpdater.compareAndSet(this, NOT_SET, SIGNALLED)) { Thread thread = this.thread; LockSupport.unpark(thread); this.thread = null; return thread; } return null; }
public boolean checkAndClear() { if (!isSet() && signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { thread = null; cleanUpCancelled(); return false; } // must now be signalled assuming correct API usage return true; }
private Thread signal() { if (!isSet() && signalledUpdater.compareAndSet(this, NOT_SET, SIGNALLED)) { Thread thread = this.thread; LockSupport.unpark(thread); this.thread = null; return thread; } return null; }
@Override public boolean checkAndClear() { context.stop(); return super.checkAndClear(); }
private Thread signal() { if (!isSet() && signalledUpdater.compareAndSet(this, NOT_SET, SIGNALLED)) { Thread thread = this.thread; LockSupport.unpark(thread); this.thread = null; return thread; } return null; }
@Override public void cancel() { if (!isCancelled()) { context.stop(); super.cancel(); } } }
@Override public boolean checkAndClear() { context.stop(); return super.checkAndClear(); }
public boolean checkAndClear() { if (!isSet() && signalledUpdater.compareAndSet(this, NOT_SET, CANCELLED)) { thread = null; cleanUpCancelled(); return false; } // must now be signalled assuming correct API usage return true; }
@Override public boolean checkAndClear() { context.stop(); return super.checkAndClear(); }
@Override public void cancel() { if (!isCancelled()) { context.stop(); super.cancel(); } } }
/** * The calling thread MUST be the thread that uses the signal * @return x */ public Signal register() { RegisteredSignal signal = new RegisteredSignal(); queue.add(signal); return signal; }
@Override public void cancel() { if (!isCancelled()) { context.stop(); super.cancel(); } } }