public interface WorkerExecutor extends Measured
It provides the same executeBlocking
operation than Context
and
Vertx
but on a separate worker pool.
Modifier and Type | Method and Description |
---|---|
default void |
close()
Close the executor.
|
<T> void |
executeBlocking(Handler<Promise<T>> blockingCodeHandler,
boolean ordered,
Handler<AsyncResult<T>> resultHandler)
Safely execute some blocking code.
|
default <T> void |
executeBlocking(Handler<Promise<T>> blockingCodeHandler,
Handler<AsyncResult<T>> resultHandler)
Like
executeBlocking(Handler, boolean, Handler) called with ordered = true. |
isMetricsEnabled
<T> void executeBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> resultHandler)
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(Object)
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.
T
- the type of the resultblockingCodeHandler
- handler representing the blocking code to runresultHandler
- handler that will be called when the blocking code is completeordered
- 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
guaranteesdefault <T> void executeBlocking(Handler<Promise<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler)
executeBlocking(Handler, boolean, Handler)
called with ordered = true.default void close()
Copyright © 2023 Eclipse. All rights reserved.