signal.cancel(); signal.awaitUninterruptibly();
public boolean await(long time, TimeUnit unit) throws InterruptedException { if (isSignaled()) return true; long start = System.nanoTime(); long until = start + unit.toNanos(time); if (waiting == null) waitingUpdater.compareAndSet(this, null, new WaitQueue()); WaitQueue.Signal s = waiting.register(); if (isSignaled()) { s.cancel(); return true; } return s.awaitUntil(until) || isSignaled(); }
totalBlocked.incrementAndGet(); currentlyBlocked.incrementAndGet(); s.awaitUninterruptibly(); currentlyBlocked.decrementAndGet(); s.cancel();
s.awaitUninterruptibly(); metrics.currentBlocked.dec(); s.cancel();
s.awaitUninterruptibly(); metrics.currentBlocked.dec(); s.cancel();
s.awaitUninterruptibly(); metrics.currentBlocked.dec(); s.cancel();
public void allocate(long size, OpOrder.Group opGroup) { assert size >= 0; while (true) { if (parent.tryAllocate(size)) { acquired(size); return; } WaitQueue.Signal signal = opGroup.isBlockingSignal(parent.hasRoom().register(parent.blockedTimerContext())); boolean allocated = parent.tryAllocate(size); if (allocated || opGroup.isBlocking()) { signal.cancel(); if (allocated) // if we allocated, take ownership acquired(size); else // otherwise we're blocking so we're permitted to overshoot our constraints, to just allocate without blocking allocated(size); return; } else signal.awaitUninterruptibly(); } }
public void allocate(long size, OpOrder.Group opGroup) { assert size >= 0; while (true) { if (parent.tryAllocate(size)) { acquired(size); return; } WaitQueue.Signal signal = opGroup.isBlockingSignal(parent.hasRoom().register()); boolean allocated = parent.tryAllocate(size); if (allocated || opGroup.isBlocking()) { signal.cancel(); if (allocated) // if we allocated, take ownership acquired(size); else // otherwise we're blocking so we're permitted to overshoot our constraints, to just allocate without blocking allocated(size); return; } else signal.awaitUninterruptibly(); } }
public void allocate(long size, OpOrder.Group opGroup) { assert size >= 0; while (true) { if (parent.tryAllocate(size)) { acquired(size); return; } WaitQueue.Signal signal = opGroup.isBlockingSignal(parent.hasRoom().register(parent.blockedTimerContext())); boolean allocated = parent.tryAllocate(size); if (allocated || opGroup.isBlocking()) { signal.cancel(); if (allocated) // if we allocated, take ownership acquired(size); else // otherwise we're blocking so we're permitted to overshoot our constraints, to just allocate without blocking allocated(size); return; } else signal.awaitUninterruptibly(); } }
public void allocate(long size, OpOrder.Group opGroup) { assert size >= 0; while (true) { if (parent.tryAllocate(size)) { acquired(size); return; } WaitQueue.Signal signal = opGroup.isBlockingSignal(parent.hasRoom().register(parent.blockedTimerContext())); boolean allocated = parent.tryAllocate(size); if (allocated || opGroup.isBlocking()) { signal.cancel(); if (allocated) // if we allocated, take ownership acquired(size); else // otherwise we're blocking so we're permitted to overshoot our constraints, to just allocate without blocking allocated(size); return; } else signal.awaitUninterruptibly(); } }
public void allocate(long size, OpOrder.Group opGroup) { assert size >= 0; while (true) { if (parent.tryAllocate(size)) { acquired(size); return; } WaitQueue.Signal signal = opGroup.isBlockingSignal(parent.hasRoom().register(parent.blockedTimerContext())); boolean allocated = parent.tryAllocate(size); if (allocated || opGroup.isBlocking()) { signal.cancel(); if (allocated) // if we allocated, take ownership acquired(size); else // otherwise we're blocking so we're permitted to overshoot our constraints, to just allocate without blocking allocated(size); return; } else signal.awaitUninterruptibly(); } }
/** * Loops waiting on the supplied condition and WaitQueue and will not return until the condition is true */ public static void waitOnCondition(BooleanSupplier condition, WaitQueue queue) { while (!condition.getAsBoolean()) { Signal s = queue.register(); if (!condition.getAsBoolean()) { s.awaitUninterruptibly(); } else { s.cancel(); } } } }
/** * Return how many threads are waiting * @return */ public int getWaiting() { if (!hasWaiters()) return 0; Iterator<RegisteredSignal> iter = queue.iterator(); int count = 0; while (iter.hasNext()) { Signal next = iter.next(); if (!next.isCancelled()) count++; } return count; }
/** * Return how many threads are waiting * @return */ public int getWaiting() { if (!hasWaiters()) return 0; Iterator<RegisteredSignal> iter = queue.iterator(); int count = 0; while (iter.hasNext()) { Signal next = iter.next(); if (!next.isCancelled()) count++; } return count; }
/** * Return how many threads are waiting * @return */ public int getWaiting() { if (!hasWaiters()) return 0; Iterator<RegisteredSignal> iter = queue.iterator(); int count = 0; while (iter.hasNext()) { Signal next = iter.next(); if (!next.isCancelled()) count++; } return count; }
/** * wait for all operations started prior to issuing the barrier to complete */ public void await() { while (!allPriorOpsAreFinished()) { WaitQueue.Signal signal = register(); if (allPriorOpsAreFinished()) { signal.cancel(); return; } else signal.awaitUninterruptibly(); } assert orderOnOrBefore.running == FINISHED; }
protected void maybeWaitForSync(CommitLogSegment.Allocation alloc) { if (waitForSyncToCatchUp(Long.MAX_VALUE)) { // wait until periodic sync() catches up with its schedule long started = System.currentTimeMillis(); pending.incrementAndGet(); while (waitForSyncToCatchUp(started)) { WaitQueue.Signal signal = syncComplete.register(CommitLog.instance.metrics.waitingOnCommit.time()); if (waitForSyncToCatchUp(started)) signal.awaitUninterruptibly(); else signal.cancel(); } pending.decrementAndGet(); } }
/** * wait for all operations started prior to issuing the barrier to complete */ public void await() { while (!allPriorOpsAreFinished()) { WaitQueue.Signal signal = register(); if (allPriorOpsAreFinished()) { signal.cancel(); return; } else signal.awaitUninterruptibly(); } assert orderOnOrBefore.running == FINISHED; }
/** * wait for all operations started prior to issuing the barrier to complete */ public void await() { while (!allPriorOpsAreFinished()) { WaitQueue.Signal signal = register(); if (allPriorOpsAreFinished()) { signal.cancel(); return; } else signal.awaitUninterruptibly(); } assert orderOnOrBefore.running == FINISHED; }