@Override public void close() { DynamicTasks.drain(null, false); releaseableLatch.release(caller); } }
/** As {@link #drain(Duration, boolean)} waiting forever and throwing the first error * (excluding errors in inessential tasks), * then returning the last task in the queue (which is guaranteed to have finished without error, * if this method returns without throwing) */ public static Task<?> waitForLast() { drain(null, true); // this call to last is safe, as the above guarantees everything will have run // (on errors the above will throw so we won't come here) List<Task<?>> q = DynamicTasks.getTaskQueuingContext().getQueue(); return q.isEmpty() ? null : Iterables.getLast(q); }
stoppingMachine = DynamicTasks.queue(stopMachineTask); DynamicTasks.drain(entity().getConfig(STOP_PROCESS_TIMEOUT), false);