class ScheduledCompletableFuture<V> extends CompletableFuture<V> implements ScheduledFuture<V> {
    // Guarded by this
    volatile Future<V> delegate;
    // Guarded by this
    Thread forkJoinPoolThread;
    private final long time;

    ScheduledCompletableFuture(long delay, TimeUnit unit) {
      this.time = System.nanoTime() + unit.toNanos(delay);
    }

    @Override
    public long getDelay(TimeUnit unit) {
      return unit.convert(time - System.nanoTime(), TimeUnit.NANOSECONDS);
    }

    @Override
    public int compareTo(Delayed other) {
      if (other == this) {
        return 0;
      } else if (other instanceof ScheduledCompletableFuture) {
        return Long.compare(time, ((ScheduledCompletableFuture<?>) other).time);
      }
      return Long.compare(getDelay(TimeUnit.NANOSECONDS), other.getDelay(TimeUnit.NANOSECONDS));
    }

    @Override
    public boolean cancel(boolean mayInterruptIfRunning) {
      boolean result = super.cancel(mayInterruptIfRunning);
      synchronized (this) {
        if (delegate != null)
          result = delegate.cancel(mayInterruptIfRunning);
        if (forkJoinPoolThread != null && mayInterruptIfRunning)
          forkJoinPoolThread.interrupt();
      }
      return result;
    }
  }

  private static ScheduledExecutorService delayer() {
    if (DELAYER == null) {
      synchronized (DelegatingScheduler.class) {
        if (DELAYER == null) {
          ScheduledThreadPoolExecutor delayer = new ScheduledThreadPoolExecutor(1, new DelayerThreadFactory());
          delayer.setRemoveOnCancelPolicy(true);
          DELAYER = delayer;
        }
      }
    }
    return DELAYER;
  }

  private ExecutorService executorService() {<FILL_FUNCTION_BODY>

    if (executorService != null)
      return executorService;
    if (FORK_JOIN_POOL == null) {
      synchronized (DelegatingScheduler.class) {
        if (FORK_JOIN_POOL == null) {
          if (ForkJoinPool.getCommonPoolParallelism() > 1)
            FORK_JOIN_POOL = ForkJoinPool.commonPool();
          else
            FORK_JOIN_POOL = new ForkJoinPool(2);
        }
      }
    }
    return FORK_JOIN_POOL;
  
<no_super_class>