Package io.smallrye.mutiny.vertx.core
Class ContextAwareScheduler.ContextCaptureStrategy
java.lang.Object
io.smallrye.mutiny.vertx.core.ContextAwareScheduler.ContextCaptureStrategy
- Enclosing interface:
- ContextAwareScheduler
Define how a scheduler captures a Vert.x
Context
.-
Method Summary
Modifier and TypeMethodDescriptionwithContext
(Context context) Actions will be run on an explicitContext
.Actions will be run on a context that is captured from the thread that is calling this method.withGetOrCreateContext
(Vertx vertx) Actions will be run on a context that is captured by callingVertx.getOrCreateContext()
when a scheduling method is being called likeScheduledExecutorService.schedule(Runnable, long, TimeUnit)
.Actions will be run on a context that is captured by callingVertx.getOrCreateContext()
on the thread that is calling this method.
-
Method Details
-
withContext
Actions will be run on an explicitContext
.- Parameters:
context
- the context, cannot benull
- Returns:
- the scheduler
-
withGetOrCreateContext
Actions will be run on a context that is captured by callingVertx.getOrCreateContext()
when a scheduling method is being called likeScheduledExecutorService.schedule(Runnable, long, TimeUnit)
.Important. Note that in many cases such as
UniDelayOnItem
the scheduling operation happens on a worker thread and not a Vert.x thread, sowithGetOrCreateContextOnCurrentThread(Vertx)
might be the better option when data is being shared through the context.- Parameters:
vertx
- the Vert.x object, cannot benull
- Returns:
- the scheduler
-
withGetOrCreateContextOnCurrentThread
Actions will be run on a context that is captured by callingVertx.getOrCreateContext()
on the thread that is calling this method. This is different towithGetOrCreateContext(Vertx)
which is late bound.- Parameters:
vertx
- the Vert.x object, cannot benull
- Returns:
- the scheduler
-
withCurrentContext
Actions will be run on a context that is captured from the thread that is calling this method. An exception is raised when the current thread is not a Vert.x thread and hence has no associatedContext
.- Returns:
- the scheduler
- Throws:
IllegalStateException
- when the current thread is not a Vert.x thread
-