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)
WorkerExecutor(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Void>
close()
Close the executor.Void
closeAndAwait()
Blocking variant ofclose()
.void
closeAndForget()
Variant ofclose()
that ignores the result of the operation.boolean
equals(Object o)
<T> io.smallrye.mutiny.Uni<T>
executeBlocking(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
LikeexecuteBlocking(io.smallrye.mutiny.Uni<T>, boolean)
called with ordered = true.<T> io.smallrye.mutiny.Uni<T>
executeBlocking(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Safely execute some blocking code.<T> T
executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
Blocking variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer)
.<T> T
executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Blocking variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer,boolean)
.<T> void
executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
Variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer)
that ignores the result of the operation.<T> void
executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Variant ofio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer,boolean)
that ignores the result of the operation.io.vertx.core.WorkerExecutor
getDelegate()
int
hashCode()
boolean
isMetricsEnabled()
static WorkerExecutor
newInstance(io.vertx.core.WorkerExecutor arg)
String
toString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<WorkerExecutor> __TYPE_ARG
-
-
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 interfaceMeasured
-
isMetricsEnabled
public boolean isMetricsEnabled()
- Specified by:
isMetricsEnabled
in interfaceMeasured
- Returns:
true
if metrics are enabled
-
executeBlocking
@CheckReturnValue 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 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
blockingCodeHandler
the current context remains the original context and therefore any task scheduled in theblockingCodeHandler
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 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
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 ofio.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 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.
-
executeBlockingAndForget
public <T> void executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Variant ofio.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 fromio.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 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
-
executeBlocking
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
LikeexecuteBlocking(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 ofio.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 ofio.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 fromio.vertx.mutiny.core.WorkerExecutor#executeBlocking(Consumer)
but you don't need to compose it with other operations.- Parameters:
blockingCodeHandler
-
-
close
@CheckReturnValue 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 ofclose()
.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()
-
newInstance
public static WorkerExecutor newInstance(io.vertx.core.WorkerExecutor arg)
-
-