code: public void setAsync(ListenableFuture<? extends V> delegate)
      {
          delegate.addListener(() -> {
              if (super.isDone()) {
                  // Opportunistically avoid calling getDone. This is critical for the performance
                  // of whenAnyCompleteCancelOthers because calling getDone for cancelled Future
                  // constructs CancellationException and populates stack trace.
                  // See BenchmarkWhenAnyCompleteCancelOthers for benchmark numbers.
                  return;
              }
  
              try {
                  set(getDone(delegate));
              }
              catch (ExecutionException e) {
                  setException(e.getCause());
              }
              catch (RuntimeException | Error e) {
                  setException(e);
              }
          }, directExecutor());
  
          super.addListener(() -> {
              if (super.isCancelled()) {
                  delegate.cancel(super.wasInterrupted());
              }
          }, directExecutor());
      }
docs: Sets this current future with the result of the delegate.
  <p>
  Values and exceptions are both propagated to this Future.
  If this Future is cancelled, than the delegate will also be cancelled
  with the same interrupt flag.