@Override public void unregister(Object registrationToken) { for(Condition cond : conditions) cond.unregister(null); }
@Override public void unregister(Object token) { if (token == null) return; SelectActionImpl<Message> action = (SelectActionImpl<Message>) token; if (action.isData()) { if (sendersSync != null) sendersSync.unregister(null); } else sync.unregister(null); }
@Override public void unregister(Object token) { if (token == null) return; Condition sync = dv.getSync(); if (sync != null) sync.unregister(null); } }
public void unlock() { sync().unregister(registrationToken); }
@Override @Suspendable public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { try { if (done) return getValue(); long left = unit.toNanos(timeout); final long deadline = System.nanoTime() + left; Object token = sync.register(); try { for (int i = 0; !done; i++) { sync.await(i, left, TimeUnit.NANOSECONDS); left = deadline - System.nanoTime(); if (left <= 0) throw new TimeoutException(); } } finally { sync.unregister(token); } return getValue(); } catch (SuspendExecution e) { throw new AssertionError(e); } }
@Override @Suspendable public V get() throws InterruptedException, ExecutionException { try { if (done) return getValue(); Object token = sync.register(); try { for (int i = 0; !done; i++) sync.await(i); } finally { sync.unregister(token); } return getValue(); } catch (SuspendExecution e) { throw new AssertionError(e); } }
void attemptReceive(long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException, TimeoutException, EOFException { checkClosed(); final Condition sync = channel.sync; long left = unit.toNanos(timeout); final long deadline = System.nanoTime() + left; Object token = sync.register(); try { for (int i = 0; !consumer.hasNext(); i++) { if (channel.isSendClosed()) { setReceiveClosed(); checkClosed(); } sync.await(i, left, TimeUnit.NANOSECONDS); left = deadline - System.nanoTime(); if (left <= 0) throw new TimeoutException(); } consumer.poll0(); } finally { sync.unregister(token); } }
} finally { if (overflowPolicy == OverflowPolicy.BLOCK) sendersSync.unregister(null);
sync.unregister(token);
boolean awaitItem(long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException, EOFException { if (unit == null) return awaitItem(); if (timeout <= 0) return queue().hasNext(); maybeSetCurrentStrandAsOwner(); Object n; long left = unit.toNanos(timeout); final long deadline = System.nanoTime() + left; Object token = sync.register(); try { for (int i = 0; !queue().hasNext(); i++) { if (isSendClosed()) { setReceiveClosed(); checkClosed(); } sync.await(i, left, TimeUnit.NANOSECONDS); left = deadline - System.nanoTime(); if (left <= 0) return false; } } finally { sync.unregister(token); } return true; }
sync.unregister(token);
boolean awaitItem() throws SuspendExecution, InterruptedException, EOFException { maybeSetCurrentStrandAsOwner(); Object n; Object token = sync.register(); for (int i = 0; !queue().hasNext(); i++) { if (isSendClosed()) { setReceiveClosed(); checkClosed(); } sync.await(i); } sync.unregister(token); return true; }
monitor.unregister(ticket);
void attemptReceive() throws EOFException, SuspendExecution, InterruptedException { checkClosed(); final Condition sync = channel.sync; Object token = sync.register(); try { for (int i = 0; !consumer.hasNext(); i++) { if (channel.isSendClosed()) { setReceiveClosed(); checkClosed(); } sync.await(i); } consumer.poll0(); } finally { sync.unregister(token); } }
@Override public Message receive() throws SuspendExecution, InterruptedException { if (receiveClosed) return closeValue(); Message m; boolean closed; final Object token = sync.register(); try { for (int i = 0;; i++) { closed = isSendClosed(); // must be read BEFORE queue.poll() if ((m = queue.poll()) != null) break; // i can be > 0 if task state is LEASED if (closed) { setReceiveClosed(); return closeValue(); } sync.await(i); } } finally { sync.unregister(token); } assert m != null; signalSenders(); return m; }
@Override public Message receive() throws SuspendExecution, InterruptedException { if (isClosed()) return null; try { maybeSetCurrentStrandAsOwner(); Message m; Object token = sync.register(); try { for (int i = 0; (m = queue().poll()) == null; i++) { if (isSendClosed()) { setReceiveClosed(); checkClosed(); } sync.await(i); } } finally { sync.unregister(token); } signalSenders(); return m; } catch (EOFException e) { return null; } }