Class: WorkerExecutor

vertx-js/worker_executor~ WorkerExecutor

new WorkerExecutor()

An executor for executing blocking code in Vert.x .




Close the executor.

executeBlocking(blockingCodeHandler, ordered, 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 (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 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.

Name Type Description
blockingCodeHandler function handler representing the blocking code to run
ordered boolean 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 function handler that will be called when the blocking code is complete

isMetricsEnabled() → {boolean}

Whether the metrics are enabled for this measured object
true if the metrics are enabled