Class SmallRyeManagedExecutor

java.lang.Object
io.smallrye.context.SmallRyeManagedExecutor
All Implemented Interfaces:
Executor, ExecutorService, org.eclipse.microprofile.context.ManagedExecutor

public class SmallRyeManagedExecutor extends Object implements org.eclipse.microprofile.context.ManagedExecutor
  • Constructor Details

  • Method Details

    • newThreadPoolExecutor

      public static ExecutorService newThreadPoolExecutor(int maxAsync, int maxQueued)
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface ExecutorService
    • shutdownNow

      public List<Runnable> shutdownNow()
      Specified by:
      shutdownNow in interface ExecutorService
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface ExecutorService
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface ExecutorService
    • awaitTermination

      public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface ExecutorService
      Throws:
      InterruptedException
    • submit

      public <T> Future<T> submit(Callable<T> task)
      Specified by:
      submit in interface ExecutorService
    • submit

      public <T> Future<T> submit(Runnable task, T result)
      Specified by:
      submit in interface ExecutorService
    • submit

      public Future<?> submit(Runnable task)
      Specified by:
      submit in interface ExecutorService
    • invokeAll

      public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
      Specified by:
      invokeAll in interface ExecutorService
      Throws:
      InterruptedException
    • invokeAll

      public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
      Specified by:
      invokeAll in interface ExecutorService
      Throws:
      InterruptedException
    • invokeAny

      public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
      Specified by:
      invokeAny in interface ExecutorService
      Throws:
      InterruptedException
      ExecutionException
    • invokeAny

      public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
      Specified by:
      invokeAny in interface ExecutorService
      Throws:
      InterruptedException
      ExecutionException
      TimeoutException
    • execute

      public void execute(Runnable command)
      Specified by:
      execute in interface Executor
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getThreadContextProviderPlan

      public ThreadContextProviderPlan getThreadContextProviderPlan()
    • getMaxAsync

      public int getMaxAsync()
    • getMaxQueued

      public int getMaxQueued()
    • getInjectionPointName

      public String getInjectionPointName()
    • builder

      public static SmallRyeManagedExecutor.Builder builder()
    • 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.

      Specified by:
      copy in interface org.eclipse.microprofile.context.ManagedExecutor
      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.

      Specified by:
      copy in interface org.eclipse.microprofile.context.ManagedExecutor
      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.
      Specified by:
      getThreadContext in interface org.eclipse.microprofile.context.ManagedExecutor
      Returns:
      a ThreadContext with the same propagation settings as this ManagedExecutor.