Class WorkerExecutor

  • All Implemented Interfaces:
    Measured

    public class WorkerExecutor
    extends Object
    implements 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.

    • Constructor Detail

      • WorkerExecutor

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

        public WorkerExecutor​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.core.WorkerExecutor getDelegate()
        Specified by:
        getDelegate in interface Measured
      • 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

        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.

        When the code is complete the handler resultHandler will be called with the result on the original context (i.e. on the original event loop of the caller).

        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 the 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

        public <T> T executeBlockingAndAwait​(io.smallrye.mutiny.Uni<T> blockingCodeHandler,
                                             boolean ordered)
        Blocking variant of io.vertx.mutiny.core.WorkerExecutor#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

        public <T> void executeBlockingAndForget​(io.smallrye.mutiny.Uni<T> blockingCodeHandler,
                                                 boolean ordered)
        Variant of io.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer>,boolean) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer>,boolean), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.WorkerExecutor#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

        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

        public <T> T executeBlockingAndAwait​(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
        Blocking variant of io.vertx.mutiny.core.WorkerExecutor#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

        public <T> void executeBlockingAndForget​(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
        Variant of io.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer>) that ignores the result of the operation.

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

        Parameters:
        blockingCodeHandler -
      • close

        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.

      • newInstance

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