code: static Task<Void> delay(long delay, ScheduledExecutorService executor, final CancellationToken cancellationToken) {
      if (cancellationToken != null && cancellationToken.isCancellationRequested()) {
        return Task.cancelled();
      }
  
      if (delay <= 0) {
        return Task.forResult(null);
      }
  
      final bolts.TaskCompletionSource<Void> tcs = new bolts.TaskCompletionSource<>();
      final ScheduledFuture<?> scheduled = executor.schedule(new Runnable() {
        @Override
        public void run() {
          tcs.trySetResult(null);
        }
      }, delay, TimeUnit.MILLISECONDS);
  
      if (cancellationToken != null) {
        cancellationToken.register(new Runnable() {
          @Override
          public void run() {
            scheduled.cancel(true);
            tcs.trySetCancelled();
          }
        });
      }
  
      return tcs.getTask();
    }
docs: /* package