public static <Result, E extends Exception> Result compute(@NotNull ThrowableComputable<Result, E> task) throws E, ProcessCanceledException {
    if (!isInCancellableContext()) {
      return task.compute();
    }

    Future<Result> future = ProcessIOExecutorService.INSTANCE.submit(task::compute);
    try {
      return ProgressIndicatorUtils.awaitWithCheckCanceled(future);
    }
    catch (ProcessCanceledException e) {
      throw e;
    }
    catch (RuntimeException wrapper) {
      Throwable outerCause = wrapper.getCause();
      if (outerCause instanceof ExecutionException) {
        Throwable t = outerCause.getCause();
        ExceptionUtil.rethrowUnchecked(t);
        @SuppressWarnings("unchecked") E innerCause = (E)t;
        throw innerCause;
      }
      else {
        throw wrapper;
      }
    }
    finally {
      //Better .cancel(true) here, but thread interruption is too intrusive, so it is cheaper
      // to allow the task to uselessly finish than to safely deal with thread interruption
      // everywhere (see IDEA-319309)
      future.cancel(false);
    }
  }
public static <Result, E extends Exception> Result compute(@NotNull ThrowableComputable<Result, E> task)