Class SmallRyeManagedExecutor

  • All Implemented Interfaces:
    Executor, ExecutorService, org.eclipse.microprofile.context.ManagedExecutor

    public class SmallRyeManagedExecutor
    extends Object
    implements org.eclipse.microprofile.context.ManagedExecutor
    • Method Detail

      • newThreadPoolExecutor

        public static ExecutorService newThreadPoolExecutor​(int maxAsync,
                                                            int maxQueued)
      • completedFuture

        public <U> CompletableFuture<U> completedFuture​(U value)
        Specified by:
        completedFuture in interface org.eclipse.microprofile.context.ManagedExecutor
      • completedStage

        public <U> CompletionStage<U> completedStage​(U value)
        Specified by:
        completedStage in interface org.eclipse.microprofile.context.ManagedExecutor
      • failedFuture

        public <U> CompletableFuture<U> failedFuture​(Throwable ex)
        Specified by:
        failedFuture in interface org.eclipse.microprofile.context.ManagedExecutor
      • failedStage

        public <U> CompletionStage<U> failedStage​(Throwable ex)
        Specified by:
        failedStage in interface org.eclipse.microprofile.context.ManagedExecutor
      • runAsync

        public CompletableFuture<Void> runAsync​(Runnable runnable)
        Specified by:
        runAsync in interface org.eclipse.microprofile.context.ManagedExecutor
      • supplyAsync

        public <U> CompletableFuture<U> supplyAsync​(Supplier<U> supplier)
        Specified by:
        supplyAsync in interface org.eclipse.microprofile.context.ManagedExecutor
      • newIncompleteFuture

        public <U> CompletableFuture<U> newIncompleteFuture()
        Specified by:
        newIncompleteFuture in interface org.eclipse.microprofile.context.ManagedExecutor
      • getMaxAsync

        public int getMaxAsync()
      • getMaxQueued

        public int getMaxQueued()
      • getInjectionPointName

        public String getInjectionPointName()
      • copy

        public <T> CompletableFuture<T> copy​(CompletableFuture<T> stage)

        Returns a new CompletableFuture that is completed by the completion of the specified stage.

        The new completable future is backed by the ManagedExecutor upon which copy is invoked, which serves as the default asynchronous execution facility for the new stage and all dependent stages created from it, and so forth.

        When dependent stages are created from the new completable future, thread context is captured and/or cleared by the ManagedExecutor. This guarantees that the action performed by each stage always runs under the thread context of the code that creates the stage, unless the user explicitly overrides by supplying a pre-contextualized action.

        Invocation of this method does not impact thread context propagation for the supplied completable future or any dependent stages created from it, other than the new dependent completable future that is created by this method.

        Type Parameters:
        T - completable future result type.
        Parameters:
        stage - a completable future whose completion triggers completion of the new completable future that is created by this method.
        Returns:
        the new completable future.
      • copy

        public <T> CompletionStage<T> copy​(CompletionStage<T> stage)

        Returns a new CompletionStage that is completed by the completion of the specified stage.

        The new completable future is backed by the ManagedExecutor upon which copy is invoked, which serves as the default asynchronous execution facility for the new stage and all dependent stages created from it, and so forth.

        When dependent stages are created from the new completable future, thread context is captured and/or cleared by the ManagedExecutor. This guarantees that the action performed by each stage always runs under the thread context of the code that creates the stage, unless the user explicitly overrides by supplying a pre-contextualized action.

        Invocation of this method does not impact thread context propagation for the supplied stage or any dependent stages created from it, other than the new dependent completion stage that is created by this method.

        Type Parameters:
        T - completion stage result type.
        Parameters:
        stage - a completion stage whose completion triggers completion of the new stage that is created by this method.
        Returns:
        the new completion stage.
      • getThreadContext

        public SmallRyeThreadContext getThreadContext()
        Returns a ThreadContext which has the same propagation settings as this ManagedExecutor, which uses this ManagedExecutor as its default executor.
        Returns:
        a ThreadContext with the same propagation settings as this ManagedExecutor.