@Test void shouldPerformTasks() throws Exception { final StubTask task = new StubTask(); final SafeFuture<String> result = executor.performTask(task); task.assertStarted(); assertThat(result).isNotDone(); task.result.complete("Done"); Waiter.waitFor(result); assertThat(result).isCompletedWithValue("Done"); }
@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();  }