code: public void register(CompletableFuture<T> toNotify) {
          T result;
          Throwable e;
          synchronized (lock) {
              if (released) {
                  result = this.result;
                  e = this.e;
              } else {
                  waitingFutures.add(toNotify);
                  return;
              }
          }
          if (e == null) {
              toNotify.complete(result);
          } else {
              toNotify.completeExceptionally(e);
          }
      }
docs: Supply a future to be notified when {@link #release(Object)} is called. If release has already been
  called, it will be completed immediately.
  
  @param toNotify The future that should be completed.