open class Context
The execution context of a io.vertx.reactivex.core.Handler execution.
When Vert.x provides an event to a handler or calls the start or stop methods of a io.vertx.reactivex.core.Verticle, the execution is associated with a Context.
Usually a context is an *event-loop context* and is tied to a specific event loop thread. So executions for that context always occur on that exact same event loop thread.
In the case of worker verticles and running inline blocking code a worker context will be associated with the execution which will use a thread from the worker thread pool.
When a handler is set by a thread associated with a specific context, the Vert.x will guarantee that when that handler is executed, that execution will be associated with the same context.
If a handler is set by a thread not associated with a context (i.e. a non Vert.x thread). Then a new context will be created for that handler.
In other words, a context is propagated.
This means that when a verticle is deployed, any handlers it sets will be associated with the same context - the context of the verticle.
This means (in the case of a standard verticle) that the verticle code will always be executed with the exact same thread, so you don't have to worry about multi-threaded acccess to the verticle state and you can code your application as single threaded.
This class also allows arbitrary data to be io.vertx.reactivex.core.Context#put and io.vertx.reactivex.core.Context#get on the context so it can be shared easily amongst different handlers of, for example, a verticle instance.
This class also provides io.vertx.reactivex.core.Context#runOnContext which allows an action to be executed asynchronously using the same context.
Context(delegate: Context) |
static val __TYPE_ARG: TypeArg<Context> |
open fun config(): JsonObject
If the context is associated with a Verticle deployment, this returns the configuration that was specified when the verticle was deployed. |
|
open fun deploymentID(): String
If the context is associated with a Verticle deployment, this returns the deployment ID of that deployment. |
|
open fun equals(other: Any?): Boolean |
|
open fun exceptionHandler(handler: Handler<Throwable>): Context
Set an exception handler called when the context runs an action throwing an uncaught throwable. When this handler is called, |
|
open fun <T : Any> executeBlocking(blockingCodeHandler: Handler<Future<T>>, ordered: Boolean, resultHandler: Handler<AsyncResult<T>>): Unit
Safely execute some blocking code. Executes the blocking code in the handler When the code is complete the handler A open fun <T : Any> executeBlocking(blockingCodeHandler: Handler<Future<T>>, resultHandler: Handler<AsyncResult<T>>): Unit
Invoke |
|
open fun <T : Any> get(key: String): T
Get some data from the context. |
|
open fun getDelegate(): Context |
|
open fun getInstanceCount(): Int |
|
open fun hashCode(): Int |
|
open fun isEventLoopContext(): Boolean
Is the current context an event loop context? NOTE! when running blocking code using |
|
open fun isMultiThreadedWorkerContext(): Boolean
Is the current context a multi-threaded worker context? |
|
open static fun isOnEventLoopThread(): Boolean
Is the current thread an event thread? NOTE! This is not always the same as calling |
|
open static fun isOnVertxThread(): Boolean
Is the current thread a Vert.x thread? That's either a worker thread or an event loop thread |
|
open static fun isOnWorkerThread(): Boolean
Is the current thread a worker thread? NOTE! This is not always the same as calling |
|
open fun isWorkerContext(): Boolean
Is the current context a worker context? NOTE! when running blocking code using |
|
open static fun newInstance(arg: Context): Context |
|
open fun owner(): Vertx |
|
open fun processArgs(): MutableList<String>
The process args |
|
open fun put(key: String, value: Any): Unit
Put some data in the context. This can be used to share data between different handlers that share a context |
|
open fun remove(key: String): Boolean
Remove some data from the context. |
|
open fun runOnContext(action: Handler<Void>): Unit
Run the specified action asynchronously on the same context, some time after the current execution has completed. |
|
open fun <T : Any> rxExecuteBlocking(blockingCodeHandler: Handler<Future<T>>, ordered: Boolean): Single<T>
Safely execute some blocking code. Executes the blocking code in the handler When the code is complete the handler A open fun <T : Any> rxExecuteBlocking(blockingCodeHandler: Handler<Future<T>>): Single<T>
Invoke |
|
open fun toString(): String |