ForkJoinPool.managedBlock(new ForkJoinPool.ManagedBlocker() {
ForkJoinPool.managedBlock(node); } catch (InterruptedException ie) { node.wasInterrupted = true;
/** * Acquire a semaphore, coordinating with the fork-join pool if one is running. * @param s The semaphore to acquire. */ public static void acquireSemaphore(Semaphore s) throws InterruptedException { ForkJoinPool.managedBlock(new SemaphoreBlocker(s)); }
/** * Enter a monitor, releasing coordinating with the fork-join pool. * @param m The monitor to enter. */ public static void enterMonitor(Monitor m) throws InterruptedException { ForkJoinPool.managedBlock(new MonitorBlocker(m)); }
private static void managedBlock( AlwaysBlockingManagedBlocker blocker) throws InterruptedException { ForkJoinPool.managedBlock(blocker); }
public void awaitOnLocalBarrier() { boolean completed = false; final IKernelBarrier barrier = localBarrier.get(); while (!completed && barrier != null) { try { ForkJoinPool.managedBlock(barrier); //ManagedBlocker already has to be reentrant completed = true; } catch (InterruptedException ex) { //Empty on purpose, either barrier is disabled on InterruptedException or lock will have to complete } } }
@Override public void run() { try { ForkJoinPool.managedBlock(this); } catch (InterruptedException ex) { LOG.log(Level.WARNING, "interrupted wait", ex); } }
@Override public ResourceLock acquire() throws InterruptedException { ForkJoinPool.managedBlock(new SingleLockManagedBlocker()); return this; }
@Override public ResourceLock acquire() throws InterruptedException { ForkJoinPool.managedBlock(new CompositeLockManagedBlocker()); return this; }
/** * Enter a monitor, releasing coordinating with the fork-join pool. * @param m The monitor to enter. */ public static void enterMonitor(Monitor m) throws InterruptedException { ForkJoinPool.managedBlock(new MonitorBlocker(m)); }
/** * Acquire a semaphore, coordinating with the fork-join pool if one is running. * @param s The semaphore to acquire. */ public static void acquireSemaphore(Semaphore s) throws InterruptedException { ForkJoinPool.managedBlock(new SemaphoreBlocker(s)); }
@Override public final void executeBlockingIO(final @NotNull Runnable task) { if (task == null) { throw new NullPointerException(); } final ManagedBlockerTask managedBlockerTask = new ManagedBlockerTask(task); try { ForkJoinPool.managedBlock(managedBlockerTask); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AssertionError("Exception of unknown cause. Please verify codebase.", e); } }
public void lockInterruptibly() throws InterruptedException { ForkJoinPool.managedBlock(new DoLockInterruptibly()); }
static <Y, Z> Z call(final Function<Y, Z> function, final Y proxy) { LOGGER.trace("Executing..."); final BlockingOperation<Z> operation = new BlockingOperation<>(() -> function.apply(proxy)); try { ForkJoinPool.managedBlock(operation); } catch (final InterruptedException ex) { LOGGER.debug("Remote operation interrupted.", ex); Thread.currentThread().interrupt(); } finally { LOGGER.trace("... done."); } return operation.getResult(); }
static <Y, Z> Z call(final Function<Y, Z> function, final Y proxy) { LOGGER.trace("Executing..."); final BlockingOperation<Z> operation = new BlockingOperation<>(() -> function.apply(proxy)); try { ForkJoinPool.managedBlock(operation); } catch (final InterruptedException ex) { LOGGER.debug("Remote operation interrupted.", ex); Thread.currentThread().interrupt(); } finally { LOGGER.trace("... done."); } return operation.getResult(); }
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { // If we already have the lock, then the TryLocker will // immediately acquire the lock due to reentrancy. We do not // really care whether we had a timeout inside the TryLocker, // but only want to return whether or not we hold the lock // at the end of the method. ForkJoinPool.managedBlock(new TryLocker(time, unit)); return isHeldByCurrentThread(); }
public void lock() { DoLock locker = new DoLock(); // we want to create this // before passing it into the lambda, to prevent it from // being created again if the thread is interrupted for some // reason Interruptions.saveForLater( () -> ForkJoinPool.managedBlock(locker)); }
public static <T> T callInManagedBlock(final Supplier<T> supplier) { final SupplierManagedBlock<T> managedBlock = new SupplierManagedBlock<>(supplier); try { ForkJoinPool.managedBlock(managedBlock); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } return managedBlock.getResult(); }
public static <T> T callInManagedBlock(final Supplier<T> supplier) { final SupplierManagedBlock<T> managedBlock = new SupplierManagedBlock<>(supplier); try { ForkJoinPool.managedBlock(managedBlock); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } return managedBlock.getResult(); }
public void waitAvail() throws InterruptedException { synchronized (this) { if (nextAvail() || atEnd()) return; } final WakeupListener w = new WakeupListener(() -> nextAvail() || atEnd()); setWakeup(w::wakeup); ForkJoinPool.managedBlock(w); }