Package: io.vertx.groovy.core

## [Groovy] Class WorkerExecutor

- io.vertx.groovy.core.WorkerExecutor

- All Implemented Interfaces and Traits:
    Measured

      @groovy.transform.CompileStatic
      class WorkerExecutor
      extends java.lang.Object

  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.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `WorkerExecutor (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `close()` Close the executor.
    `void` | `executeBlocking(io.vertx.core.Handler<Future<T>> blockingCodeHandler, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> resultHandler)` Safely execute some blocking code.
    `void` | `executeBlocking(io.vertx.core.Handler<Future<T>> blockingCodeHandler, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> resultHandler)` Like WorkerExecutor.executeBlocking called with ordered = true.
    `java.lang.Object` | `getDelegate()`
    `boolean` | `isMetricsEnabled()` Whether the metrics are enabled for this measured object

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### WorkerExecutor(java.lang.Object delegate)

  - ### Method Detail

    - #### void close()

      Close the executor.

    - #### void executeBlocking(io.vertx.core.Handler<Future<T>> blockingCodeHandler, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> resultHandler)

      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 (e.g. 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 Future.complete or Future.complete method, or the Future.fail 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.

      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
        `resultHandler` - handler that will be called when the blocking code is complete

    - #### void executeBlocking(io.vertx.core.Handler<Future<T>> blockingCodeHandler, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> resultHandler)

      Like WorkerExecutor.executeBlocking called with ordered = true.

      Parameters:
        blockingCodeHandler
        resultHandler

    - #### java.lang.Object getDelegate()

    - #### boolean isMetricsEnabled()

      Whether the metrics are enabled for this measured object

      Returns:
        true if the metrics are enabled