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 Deprecated 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> io.smallrye.mutiny.Uni<T>
executeBlocking(Callable<T> blockingCodeHandler)
LikeexecuteBlocking(io.smallrye.mutiny.Uni<T>, boolean)
but using a callback.<T> io.smallrye.mutiny.Uni<T>
executeBlocking(Callable<T> blockingCodeHandler, boolean ordered)
LikeexecuteBlocking(io.smallrye.mutiny.Uni<T>, boolean)
but using a callback.<T> T
executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
Deprecated.instead useexecuteBlocking(Callable)
<T> T
executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Deprecated.instead useexecuteBlocking(Callable, boolean)
<T> T
executeBlockingAndAwait(Callable<T> blockingCodeHandler)
Blocking variant ofexecuteBlocking(Callable)
.<T> T
executeBlockingAndAwait(Callable<T> blockingCodeHandler, boolean ordered)
Blocking variant ofexecuteBlocking(Callable,boolean)
.<T> void
executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
Deprecated.instead useexecuteBlocking(Callable)
<T> void
executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Deprecated.instead useexecuteBlocking(Callable, boolean)
<T> void
executeBlockingAndForget(Callable<T> blockingCodeHandler)
Variant ofexecuteBlocking(Callable)
that ignores the result of the operation.<T> void
executeBlockingAndForget(Callable<T> blockingCodeHandler, boolean ordered)
Variant ofexecuteBlocking(Callable,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.The returned future will be completed with the result on the original context (i.e. on the original event loop of the caller) or failed when the handler throws an exception.
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 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
@Deprecated public <T> T executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Deprecated.instead useexecuteBlocking(Callable, boolean)
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
@Deprecated public <T> void executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler, boolean ordered)
Deprecated.instead useexecuteBlocking(Callable, boolean)
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
@Deprecated public <T> T executeBlockingAndAwait(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
Deprecated.instead useexecuteBlocking(Callable)
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
@Deprecated public <T> void executeBlockingAndForget(io.smallrye.mutiny.Uni<T> blockingCodeHandler)
Deprecated.instead useexecuteBlocking(Callable)
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()
-
executeBlocking
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(Callable<T> blockingCodeHandler)
LikeexecuteBlocking(io.smallrye.mutiny.Uni<T>, boolean)
but using a callback.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(Callable<T> blockingCodeHandler)
Blocking variant ofexecuteBlocking(Callable)
.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(Callable<T> blockingCodeHandler)
Variant ofexecuteBlocking(Callable)
that ignores the result of the operation.This method subscribes on the result of
executeBlocking(Callable)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromexecuteBlocking(Callable)
but you don't need to compose it with other operations.- Parameters:
blockingCodeHandler
-
-
executeBlocking
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeBlocking(Callable<T> blockingCodeHandler, boolean ordered)
LikeexecuteBlocking(io.smallrye.mutiny.Uni<T>, boolean)
but using a callback.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
blockingCodeHandler
-ordered
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
executeBlockingAndAwait
public <T> T executeBlockingAndAwait(Callable<T> blockingCodeHandler, boolean ordered)
Blocking variant ofexecuteBlocking(Callable,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
-ordered
-- Returns:
- the T instance produced by the operation.
-
executeBlockingAndForget
public <T> void executeBlockingAndForget(Callable<T> blockingCodeHandler, boolean ordered)
Variant ofexecuteBlocking(Callable,boolean)
that ignores the result of the operation.This method subscribes on the result of
executeBlocking(Callable,boolean)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromexecuteBlocking(Callable,boolean)
but you don't need to compose it with other operations.- Parameters:
blockingCodeHandler
-ordered
-
-
newInstance
public static WorkerExecutor newInstance(io.vertx.core.WorkerExecutor arg)
-
-