Class WorkerExecutor
- java.lang.Object
-
- io.vertx.mutiny.core.WorkerExecutor
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<WorkerExecutor>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description WorkerExecutor(io.vertx.core.WorkerExecutor delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanequals(Object o)<T> io.smallrye.mutiny.Uni<T>executeBlocking(io.vertx.core.Handler<Promise<T>> blockingCodeHandler)LikeexecuteBlocking(io.vertx.core.Handler<io.vertx.mutiny.core.Promise<T>>, boolean)called with ordered = true.<T> io.smallrye.mutiny.Uni<T>executeBlocking(io.vertx.core.Handler<Promise<T>> blockingCodeHandler, boolean ordered)Safely execute some blocking code.<T> TexecuteBlockingAndAwait(io.vertx.core.Handler<Promise<T>> blockingCodeHandler)Blocking variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Handler.>) <T> TexecuteBlockingAndAwait(io.vertx.core.Handler<Promise<T>> blockingCodeHandler, boolean ordered)Blocking variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Handler.>,boolean) io.vertx.core.WorkerExecutorgetDelegate()inthashCode()booleanisMetricsEnabled()static WorkerExecutornewInstance(io.vertx.core.WorkerExecutor arg)StringtoString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<WorkerExecutor> __TYPE_ARG
-
-
Method Detail
-
getDelegate
public io.vertx.core.WorkerExecutor getDelegate()
- Specified by:
getDelegatein interfaceMeasured
-
isMetricsEnabled
public boolean isMetricsEnabled()
- Specified by:
isMetricsEnabledin interfaceMeasured- Returns:
trueif metrics are enabled
-
executeBlocking
public <T> io.smallrye.mutiny.Uni<T> executeBlocking(io.vertx.core.Handler<Promise<T>> blockingCodeHandler, boolean ordered)
Safely execute some blocking code.Executes the blocking code in the handler
blockingCodeHandlerusing a thread from the worker pool.When the code is complete the handler
resultHandlerwill be called with the result on the original context (i.e. on the original event loop of the caller).A
Futureinstance is passed intoblockingCodeHandler. When the blocking code successfully completes, the handler should call thePromise.complete(T)orPromise.complete(T)method, or thePromise.fail(java.lang.Throwable)method if it failed.In the
blockingCodeHandlerthe current context remains the original context and therefore any task scheduled in theblockingCodeHandlerwill 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 runordered- 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
executeBlockingAndAwait
public <T> T executeBlockingAndAwait(io.vertx.core.Handler<Promise<T>> blockingCodeHandler, boolean ordered)
Blocking variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Handler.>,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 runordered- 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
-
executeBlocking
public <T> io.smallrye.mutiny.Uni<T> executeBlocking(io.vertx.core.Handler<Promise<T>> blockingCodeHandler)
LikeexecuteBlocking(io.vertx.core.Handler<io.vertx.mutiny.core.Promise<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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
executeBlockingAndAwait
public <T> T executeBlockingAndAwait(io.vertx.core.Handler<Promise<T>> blockingCodeHandler)
Blocking variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Handler.>) 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
-
close
public void close()
-
newInstance
public static WorkerExecutor newInstance(io.vertx.core.WorkerExecutor arg)
-
-