@Test void shouldNotExecuteNextTaskUntilFirstIsComplete() throws Exception { final StubTask task1 = new StubTask(); final StubTask task2 = new StubTask(); final SafeFuture<String> result1 = executor.performTask(task1); final SafeFuture<String> result2 = executor.performTask(task2); task1.assertStarted(); assertThat(task2.started).isFalse(); task1.result.complete("Foo"); Waiter.waitFor(result1); task2.assertStarted(); task2.result.complete("Bar"); Waiter.waitFor(result2); assertThat(result1).isCompletedWithValue("Foo"); assertThat(result2).isCompletedWithValue("Bar"); }
@Override public <T> SafeFuture<T> performTask(final ForkChoiceTask<T> task) { final SafeFuture<T> result = new SafeFuture<>(); try { executor.execute(() -> syncPerformTask(task).propagateTo(result)); } catch (final RejectedExecutionException e) { if (stopped.get()) { LOG.debug("Ignoring fork choice task because shutdown is in progress"); } else { result.completeExceptionally(e); } } catch (final Throwable t) { result.completeExceptionally(t); } return result; }
SingleThreadedForkChoiceExecutor implements ForkChoiceExecutor { @Override public <T> SafeFuture<T> performTask(final ForkChoiceTask<T> task) { final SafeFuture<T> result = new SafeFuture<>(); try { executor.execute(() -> syncPerformTask(task).propagateTo(result)); } catch (final RejectedExecutionException e) { if (stopped.get()) { LOG.debug("Ignoring fork choice task because shutdown is in progress"); } else { result.completeExceptionally(e); } } catch (final Throwable t) { result.completeExceptionally(t); } return result; } }
SingleThreadedForkChoiceExecutor implements ForkChoiceExecutor { @Override public <T> SafeFuture<T> performTask(final ForkChoiceTask<T> task) { final SafeFuture<T> result = new SafeFuture<>(); try { executor.execute(() -> syncPerformTask(task).propagateTo(result)); } catch (final RejectedExecutionException e) { if (stopped.get()) { LOG.debug("Ignoring fork choice task because shutdown is in progress"); } else { result.completeExceptionally(e); } } catch (final Throwable t) { result.completeExceptionally(t); } return result; } private  SingleThreadedForkChoiceExecutor(final ExecutorService executor); }
SingleThreadedForkChoiceExecutor implements ForkChoiceExecutor { @Override public <T> SafeFuture<T> performTask(final ForkChoiceTask<T> task) { final SafeFuture<T> result = new SafeFuture<>(); try { executor.execute(() -> syncPerformTask(task).propagateTo(result)); } catch (final RejectedExecutionException e) { if (stopped.get()) { LOG.debug("Ignoring fork choice task because shutdown is in progress"); } else { result.completeExceptionally(e); } } catch (final Throwable t) { result.completeExceptionally(t); } return result; } private  SingleThreadedForkChoiceExecutor(final ExecutorService executor); static ForkChoiceExecutor create(); @Override SafeFuture<T> performTask(final ForkChoiceTask<T> task); @Override void stop(); }
SingleThreadedForkChoiceExecutor implements ForkChoiceExecutor { @Override public <T> SafeFuture<T> performTask(final ForkChoiceTask<T> task) { final SafeFuture<T> result = new SafeFuture<>(); try { executor.execute(() -> syncPerformTask(task).propagateTo(result)); } catch (final RejectedExecutionException e) { if (stopped.get()) { LOG.debug("Ignoring fork choice task because shutdown is in progress"); } else { result.completeExceptionally(e); } } catch (final Throwable t) { result.completeExceptionally(t); } return result; } private  SingleThreadedForkChoiceExecutor(final ExecutorService executor); static ForkChoiceExecutor create(); @Override SafeFuture<T> performTask(final ForkChoiceTask<T> task); @Override void stop();  }