Package org.incendo.cloud.execution
Interface ExecutionCoordinator<C>
- Type Parameters:
C- command sender type
The
execution coordinator is responsible for coordinating execution of command parsing,
handlers, suggestions, etc. It can determine what thread context certain stages of the pipeline will run in, allowing it to
for example, disallow concurrent command execution.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <C> @NonNull ExecutionCoordinator<C> Create a new execution coordinator that schedules tothe common poolat every possible point in the pipeline.static <C> @NonNull ExecutionCoordinator.Builder<C> builder()Creates a newExecutionCoordinator.Builder.coordinateExecution(@NonNull CommandTree<C> commandTree, @NonNull CommandContext<C> commandContext, @NonNull CommandInput commandInput) Coordinate the execution of a command and return the result<S extends Suggestion>
@NonNull CompletableFuture<@NonNull Suggestions<C, S>> coordinateSuggestions(@NonNull CommandTree<C> commandTree, @NonNull CommandContext<C> context, @NonNull CommandInput commandInput, @NonNull SuggestionMapper<S> mapper) Coordinates the execution of a suggestions query.static <C> @NonNull ExecutionCoordinator<C> coordinatorFor(@NonNull Executor executor) Create a new execution coordinator that schedules toexecutorat every possible point in the pipeline.Returns the non-scheduling executor.static <C> @NonNull ExecutionCoordinator<C> Create a new execution coordinator that does not make any attempt to schedule tasks to a particular executor.
-
Method Details
-
builder
Creates a newExecutionCoordinator.Builder.- Type Parameters:
C- command sender type- Returns:
- new
ExecutionCoordinator.Builder
-
simpleCoordinator
Create a new execution coordinator that does not make any attempt to schedule tasks to a particular executor. Parsing and suggestions will run on the calling thread until redirected by a parser, suggestion provider, or similar, at which point execution will continue on that thread.- Type Parameters:
C- command sender type- Returns:
- new coordinator
-
coordinatorFor
Create a new execution coordinator that schedules toexecutorat every possible point in the pipeline.- Type Parameters:
C- command sender type- Parameters:
executor- executor to use- Returns:
- new coordinator
-
asyncCoordinator
Create a new execution coordinator that schedules tothe common poolat every possible point in the pipeline.- Type Parameters:
C- command sender type- Returns:
- new coordinator
-
coordinateExecution
@NonNull CompletableFuture<CommandResult<C>> coordinateExecution(@NonNull CommandTree<C> commandTree, @NonNull CommandContext<C> commandContext, @NonNull CommandInput commandInput) Coordinate the execution of a command and return the result- Parameters:
commandTree- command tree to suggest fromcommandContext- command contextcommandInput- command input- Returns:
- future that completes with the result
-
coordinateSuggestions
<S extends Suggestion> @NonNull CompletableFuture<@NonNull Suggestions<C,S>> coordinateSuggestions(@NonNull CommandTree<C> commandTree, @NonNull CommandContext<C> context, @NonNull CommandInput commandInput, @NonNull SuggestionMapper<S> mapper) Coordinates the execution of a suggestions query.- Type Parameters:
S- suggestion type- Parameters:
commandTree- command tree to suggest fromcontext- command contextcommandInput- command inputmapper- suggestion mapper- Returns:
- future that completes with the result
-
nonSchedulingExecutor
Returns the non-scheduling executor. This is an executor that simply invokesRunnable.run()immediately on the calling thread ofExecutor.execute(Runnable).- Returns:
- the non-scheduling executor
-