public <T> CancellablePromise<T> submit(@NotNull Callable<? extends T> task) {
    final AsyncPromise<T> promise = new AsyncPromise<>();
    if (myExpiration != null) {
      final Expiration.Handle expirationHandle = myExpiration.invokeOnExpiration(promise::cancel);
      promise.onProcessed(value -> expirationHandle.unregisterHandler());
    }

    final BooleanSupplier condition = () -> {
      if (promise.isCancelled()) return false;
      if (myExpiration != null && myExpiration.isExpired()) return false;
      if (myCancellationCondition != null && myCancellationCondition.getAsBoolean()) {
        promise.cancel();
        return false;
      }
      return true;
    };
    myExecutionScheduler.scheduleWithinConstraints(() -> {
      try {
        final T result = task.call();
        promise.setResult(result);
      }
      catch (Throwable e){
        promise.setError(e);
      }
    }, condition);
    return promise;
  }
public <T> CancellablePromise<T> submit(@NotNull Callable<? extends T> task)