Class WorkerExecutor

java.lang.Object
io.vertx.mutiny.core.WorkerExecutor
All Implemented Interfaces:
MutinyDelegate, Measured

public class WorkerExecutor extends Object implements MutinyDelegate, Measured
An executor for executing blocking code in Vert.x .

It provides the same executeBlocking operation than Context and Vertx but on a separate worker pool.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • WorkerExecutor

      public WorkerExecutor(io.vertx.core.WorkerExecutor delegate)
    • WorkerExecutor

      public WorkerExecutor(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.core.WorkerExecutor getDelegate()
      Specified by:
      getDelegate in interface Measured
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isMetricsEnabled

      public boolean isMetricsEnabled()
      Specified by:
      isMetricsEnabled in interface Measured
      Returns:
      true if metrics are enabled
    • executeBlocking

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
      Safely execute some blocking code.

      Executes the blocking code in the handler blockingCodeHandler using a thread from the worker pool.

      The returned future will be completed with the result on the original context (i.e. on the original event loop of the caller) or failed when the handler throws an exception.

      A Future instance is passed into blockingCodeHandler. When the blocking code successfully completes, the handler should call the Promise.complete(T) or Promise.complete(T) method, or the Promise.fail(java.lang.Throwable) method if it failed.

      In the blockingCodeHandler the current context remains the original context and therefore any task scheduled in the blockingCodeHandler will be executed on this context and not on the worker thread.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      blockingCodeHandler - handler representing the blocking code to run
      ordered - if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeBlockingAndAwait

      @Deprecated public <T> T executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
      Deprecated.
      Blocking variant of executeBlocking(Consumer,boolean).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      blockingCodeHandler - handler representing the blocking code to run
      ordered - if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
      Returns:
      the T instance produced by the operation.
    • executeBlockingAndForget

      @Deprecated public <T> void executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
      Deprecated.
      Variant of executeBlocking(Consumer,boolean) that ignores the result of the operation.

      This method subscribes on the result of executeBlocking(Consumer,boolean), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from executeBlocking(Consumer,boolean) but you don't need to compose it with other operations.

      Parameters:
      blockingCodeHandler - handler representing the blocking code to run
      ordered - if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
    • executeBlocking

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
      Like executeBlocking(io.smallrye.mutiny.Uni<T>, boolean) called with ordered = true.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      blockingCodeHandler -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeBlockingAndAwait

      @Deprecated public <T> T executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
      Deprecated.
      Blocking variant of executeBlocking(Consumer).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      blockingCodeHandler -
      Returns:
      the T instance produced by the operation.
    • executeBlockingAndForget

      @Deprecated public <T> void executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
      Deprecated.
      Variant of executeBlocking(Consumer) that ignores the result of the operation.

      This method subscribes on the result of executeBlocking(Consumer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from executeBlocking(Consumer) but you don't need to compose it with other operations.

      Parameters:
      blockingCodeHandler -
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the executor.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • closeAndAwait

      public Void closeAndAwait()
      Blocking variant of close().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Void instance produced by the operation.
    • closeAndForget

      public void closeAndForget()
      Variant of close() that ignores the result of the operation.

      This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

    • executeBlocking

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(Callable<T> blockingCodeHandler)
      Like executeBlocking(io.smallrye.mutiny.Uni<T>, boolean) but using a callback.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      blockingCodeHandler -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeBlockingAndAwait

      public <T> T executeBlockingAndAwait(Callable<T> blockingCodeHandler)
      Blocking variant of executeBlocking(Callable).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      blockingCodeHandler -
      Returns:
      the T instance produced by the operation.
    • executeBlockingAndForget

      public <T> void executeBlockingAndForget(Callable<T> blockingCodeHandler)
      Variant of executeBlocking(Callable) that ignores the result of the operation.

      This method subscribes on the result of executeBlocking(Callable), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from executeBlocking(Callable) but you don't need to compose it with other operations.

      Parameters:
      blockingCodeHandler -
    • executeBlocking

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(Callable<T> blockingCodeHandler, boolean ordered)
      Like executeBlocking(io.smallrye.mutiny.Uni<T>, boolean) but using a callback.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      blockingCodeHandler -
      ordered -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeBlockingAndAwait

      public <T> T executeBlockingAndAwait(Callable<T> blockingCodeHandler, boolean ordered)
      Blocking variant of executeBlocking(Callable,boolean).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      blockingCodeHandler -
      ordered -
      Returns:
      the T instance produced by the operation.
    • executeBlockingAndForget

      public <T> void executeBlockingAndForget(Callable<T> blockingCodeHandler, boolean ordered)
      Variant of executeBlocking(Callable,boolean) that ignores the result of the operation.

      This method subscribes on the result of executeBlocking(Callable,boolean), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from executeBlocking(Callable,boolean) but you don't need to compose it with other operations.

      Parameters:
      blockingCodeHandler -
      ordered -
    • newInstance

      public static WorkerExecutor newInstance(io.vertx.core.WorkerExecutor arg)