Performs an async execution by first doing an optional pre-execute, calling the next executor, else scheduling the
executor's supplier, then finally doing an async post-execute.
543727
protected Supplier<CompletableFuture<ExecutionResult>> supplyAsync(
      Supplier<CompletableFuture<ExecutionResult>> supplier, Scheduler scheduler, FailsafeFuture<Object> future) {
    return () -> {
      ExecutionResult result = preExecute();
      if (result != null)
        return CompletableFuture.completedFuture(result);

      return supplier.get().thenCompose(s -> postExecuteAsync(s, scheduler, future));
    };
  }
465986
public Future<T> executeAsync() {

        return client.submit(new Callable<T>() {

            @Override
            public T call() throws Exception {
                return execute();
            }
        });
    }
652738
def execute_async(self, command, callback=None):
        
        try:
            logger.debug(('{0}: execute async "{1}"'
                          'with callback {2}'.format(self.target_address,
                                                     command,
                                                     callback)))
            future = self.executor.submit(self.execute, command)
            if callback is not None:
                future.add_done_callback(callback)
            return future
        except (AuthenticationException, SSHException,
                ChannelException, SocketError) as ex:
            logger.critical(("{0} execution failed on {1} with exception:"
                             "{2}".format(command, self.target_address,
                                               ex)))
            raise SSHCommandError(self.target_address, command, ex)
896031
def prepare(executor = @service.executor)
      @normal_future = initial_normal(executor, &@normal_block)
      @normal_future.add_observer do |_, value, reason|
        if reason # failure
          if @fallback_block
            future = RichFuture.new(executor: executor) do
              success, value, reason = Concurrent::SafeTaskExecutor.new(@fallback_block, rescue_exception: true).execute(reason)
              if success
                @ivar.set(value)
              else
                @ivar.fail(reason)
              end
            end
            future.safe_execute
          else
            @ivar.fail(reason)
          end
        else # success
          @ivar.set(value)
        end
      end

      @dependencies.each(&:start)
    end
756537
@Override
  public void execute(Runnable r) {
    Preconditions.checkNotNull(r, "'r' must not be null.");
    boolean scheduleTaskRunner = false;
    synchronized (internalLock) {
      waitQueue.add(r);

      if (!isThreadScheduled) {
        isThreadScheduled = true;
        scheduleTaskRunner = true;
      }
    }
    if (scheduleTaskRunner) {
      boolean threw = true;
      try {
        executor.execute(taskRunner);
        threw = false;
      } finally {
        if (threw) {
          synchronized (internalLock) {
            // It is possible that at this point that there are still tasks in
            // the queue, it would be nice to keep trying but the error may not
            // be recoverable.  So we update our state and propogate so that if
            // our caller deems it recoverable we won't be stuck.
            isThreadScheduled = false;
          }
        }
      }
    }
  }
945534
private void executeTaskAsync() {
        final String taskId = currentTask.getId();

        ListenableFuture<?> future = taskExecutorService.submit(currentTask);
        pendingTasks.put(taskId, future);

        future.addListener(new Runnable() {
            @Override
            public void run() {
                pendingTasks.remove(taskId);
            }
        }, MoreExecutors.sameThreadExecutor());

        hasCurrentTask = false;
    }
292316
private void executeQueryPrologue(ServerPrepareResult serverPrepareResult) throws SQLException {
    executing = true;
    if (closed) {
      throw new SQLException("execute() is called on closed statement");
    }
    protocol
        .prologProxy(serverPrepareResult, maxRows, protocol.getProxy() != null, connection, this);

  }
1064100
public void executeAsyncDelayed(final long delay) {
		final Executable nestedExec = this;
		helperExecutable = new Executable() {
			public Object execute() throws Throwable {
				return nestedExec.executeDelayed(delay);
			}
		};
		helperExecutable.executeAsync();
	}
263744
private <T> CompletableFuture<T> executeOnTransientConnection(
      Address address,
      Function<ClientConnection, CompletableFuture<T>> callback,
      Executor executor) {
    CompletableFuture<T> future = new CompletableFuture<>();
    if (address.equals(returnAddress)) {
      callback.apply(localConnection).whenComplete((result, error) -> {
        if (error == null) {
          executor.execute(() -> future.complete(result));
        } else {
          executor.execute(() -> future.completeExceptionally(error));
        }
      });
      return future;
    }

    openChannel(address).whenComplete((channel, channelError) -> {
      if (channelError == null) {
        callback.apply(getOrCreateClientConnection(channel)).whenComplete((result, sendError) -> {
          if (sendError == null) {
            executor.execute(() -> future.complete(result));
          } else {
            executor.execute(() -> future.completeExceptionally(sendError));
          }
          channel.close();
        });
      } else {
        executor.execute(() -> future.completeExceptionally(channelError));
      }
    });
    return future;
  }
412360
@Override
    public void execute() {
        for (Task t : tasks) {
            if (t instanceof UnknownElement) {
                t.maybeConfigure();
                Object proxy = ((UnknownElement) t).getWrapper().getProxy();
                if (proxy instanceof AbstractTaskElement) {
                    ((AbstractTaskElement) proxy).setExpect(expect);
                }
            }
        }
        super.execute();
    }
1291081
protected CompletableFuture<ExecutionResult> postExecuteAsync(ExecutionResult result, Scheduler scheduler,
      FailsafeFuture<Object> future) {
    if (isFailure(result)) {
      result = result.with(false, false);
      return onFailureAsync(result, scheduler, future).whenComplete((postResult, error) -> {
        callFailureListener(postResult);
      });
    } else {
      result = result.with(true, true);
      onSuccess(result);
      callSuccessListener(result);
      return CompletableFuture.completedFuture(result);
    }
  }
1282564
def execute(self):
        
        stack = self._stack
        callbacks = self._callbacks
        self._stack = []
        self._callbacks = []

        deferred = []

        build = self._nested_future

        pipe = self._pipeline(self.connection_name)
        for item, args, kwargs, ref in stack:
            f = getattr(pipe, item)
            deferred.append(build(f(*args, **kwargs), ref))

        inject_callbacks = getattr(self.parent, '_inject_callbacks')
        inject_callbacks(deferred + callbacks)
591904
private static void doExecute(Executor executor, Runnable runnable) {
    try {
      executor.execute(runnable);
    } catch (Throwable th) {
      log.log(Level.SEVERE, "Failed to execute PingCallback", th);
    }
  }
539864
public void completeExecutorTask()
  {
    ExecutorQueueItem item = null;

    synchronized (_executorLock) {
      _executorTaskCount--;

      assert(_executorTaskCount >= 0);

      if (_executorQueueHead != null) {
        item = _executorQueueHead;

        _executorQueueHead = item._next;

        if (_executorQueueHead == null)
          _executorQueueTail = null;
      }
    }

    if (item != null) {
      Runnable task = item.getRunnable();
      ClassLoader loader = item.getLoader();

      boolean isPriority = false;
      boolean isQueue = true;
      boolean isWake = true;

      scheduleImpl(task, loader, MAX_EXPIRE, isPriority, isQueue, isWake);
    }
  }
1106132
public final void execute() {
        try {
            Matcher<R> matcher = createMatcher();
            R result;
            if (input == null && timeout == null) {
                result = getExpect().expect(matcher);
            } else if (timeout == null) {
                result = getExpect().expectIn(input, matcher);
            } else if (input == null) {
                result = getExpect().expect(timeout, matcher);
            } else {
                result = getExpect().expectIn(input, timeout, matcher);
            }
            exportSuccessfulResult(resultPrefix, result);
        } catch (IOException e) {
            throw new BuildException(e);
        }
    }
17174
def perform_after(time, block=nil)
      task = Concurrent::ScheduledTask.new(time) do
        block = ->(){ yield } unless block
        self.async.perform_now block
      end
      task.execute
      task
    end
308736
def _execute_callback(self, callback, data):
        """"""
        web_client = WebClient(
            token=self.token, base_url=self.base_url, ssl=self.ssl, proxy=self.proxy
        )
        with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
            # Execute the callback on a separate thread,
            future = executor.submit(
                callback, rtm_client=self, web_client=web_client, data=data
            )

            while future.running():
                pass

            future.result()