@Test public void onShutdownCompletesAllTasksThatHadBeenSubmittedPriorToShutdown() throws Exception { KeySerializingExecutor keySerializingExecutor = new WrappingKeySerializingExecutor(fixedThreadExecutor); List<Integer> log = submitSeveralTasksAndBeginLoggingTheirInvocations(keySerializingExecutor, "key"); keySerializingExecutor.shutdownAndAwaitTermination(1, TimeUnit.SECONDS); assertThat(log, containsRecordOfEveryTask()); }
@Override public void shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (getAndSetShutdown()) { return; } flushAllQueues(timeout, unit); shutdownInternalExecutorService(timeout, unit); }
WrappingKeySerializingExecutor implements KeySerializingExecutor { @Override public void shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (getAndSetShutdown()) { return; } flushAllQueues(timeout, unit); shutdownInternalExecutorService(timeout, unit); } }
WrappingKeySerializingExecutor implements KeySerializingExecutor { @Override public void shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (getAndSetShutdown()) { return; } flushAllQueues(timeout, unit); shutdownInternalExecutorService(timeout, unit); } WrappingKeySerializingExecutor(ExecutorService executorService); }
WrappingKeySerializingExecutor implements KeySerializingExecutor { @Override public void shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (getAndSetShutdown()) { return; } flushAllQueues(timeout, unit); shutdownInternalExecutorService(timeout, unit); } WrappingKeySerializingExecutor(ExecutorService executorService); @Override ListenableFuture<T> submit(String key, CheckedSupplier<T, Exception> task); @Override void shutdownAndAwaitTermination(long timeout, TimeUnit unit); }
WrappingKeySerializingExecutor implements KeySerializingExecutor { @Override public void shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (getAndSetShutdown()) { return; } flushAllQueues(timeout, unit); shutdownInternalExecutorService(timeout, unit); } WrappingKeySerializingExecutor(ExecutorService executorService); @Override ListenableFuture<T> submit(String key, CheckedSupplier<T, Exception> task); @Override void shutdownAndAwaitTermination(long timeout, TimeUnit unit);  }