public static <T> CompletableFuture<T> reschedule(CompletableFuture<T> future) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    DebuggerManagerThreadImpl thread = (DebuggerManagerThreadImpl)InvokeThread.currentThread();
    LOG.assertTrue(thread != null);
    DebuggerCommandImpl event = DebuggerManagerThreadImpl.getCurrentCommand();
    LOG.assertTrue(event != null);
    PrioritizedTask.Priority priority = event.getPriority();
    SuspendContextImpl suspendContext =
      event instanceof SuspendContextCommandImpl ? ((SuspendContextCommandImpl)event).getSuspendContext() : null;

    CompletableFuture<T> res = new DebuggerCompletableFuture<>();
    future.whenComplete((r, ex) -> {
      if (DebuggerManagerThreadImpl.isManagerThread()) {
        completeFuture(r, ex, res);
      }
      else if (suspendContext != null) {
        thread.schedule(new SuspendContextCommandImpl(suspendContext) {
          @Override
          public Priority getPriority() {
            return priority;
          }

          @Override
          public void contextAction(@NotNull SuspendContextImpl suspendContext) {
            completeFuture(r, ex, res);
          }

          @Override
          protected void commandCancelled() {
            res.cancel(false);
          }
        });
      }
      else {
        thread.schedule(new DebuggerCommandImpl(priority) {
          @Override
          protected void action() {
            completeFuture(r, ex, res);
          }

          @Override
          protected void commandCancelled() {
            res.cancel(false);
          }
        });
      }
    });
    return res;
  }
public static <T> CompletableFuture<T> reschedule(CompletableFuture<T> future)