Top Description Fields Constructors Methods
io.vertx.core.impl

pack-priv final Class DuplicatedContext

extends ContextBase
implements ContextInternal
Class Inheritance
All Implemented Interfaces
io.vertx.core.impl.ContextInternal, io.vertx.core.Context
Imports
io.netty.channel.EventLoop, io.vertx.core.*, io.vertx.core.json.JsonObject, io.vertx.core.spi.tracing.VertxTracer, java.util.concurrent.Callable, .ConcurrentMap, .Executor

A context that forwards most operations to a delegate. This context
Author
Julien Viet

Field Summary

Modifier and TypeField and Description
pack-priv final ContextImpl
Inherited from io.vertx.core.impl.ContextBase:
localsLength

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final ClassLoader
public Future<Void>
close()

Implements io.vertx.core.impl.ContextInternal.close.

Close this context, cleanup close future hooks then dispose pending ordered task queue.

public final CloseFuture
public final JsonObject
config()

Implements io.vertx.core.Context.config.

References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

If the context is associated with a Verticle deployment, this returns the configuration that was specified when the verticle was deployed.

public final ConcurrentMap<Object, Object>
public ContextInternal
duplicate()

Implements io.vertx.core.impl.ContextInternal.duplicate.

Returns a context sharing with this context

  • the same concurrency
  • the same exception handler
  • the same context data
  • the same deployment
  • the same config
  • the same classloader
public <T> void
emit(T
the task argument
argument
,
Handler<T>
the handler to execute with the event argument
task
)

Implements io.vertx.core.impl.ContextInternal.emit.

Emit the given argument event to the task and switch on this context if necessary, this also associates the current thread with the current context so Vertx#currentContext() returns this context.

public final Context
public final Handler<Throwable>
public final <T> void
execute(T
the task argument
argument
,
Handler<T>
the task to execute
task
)

Implements io.vertx.core.impl.ContextInternal.execute.

Execute a task on this context, the task will be executed according to the context concurrency model.

public void
execute(Runnable
the task to execute
task
)

Implements io.vertx.core.impl.ContextInternal.execute.

Execute the task on this context, it will be executed according to the context concurrency model.

public final <T> Future<T>
executeBlocking(Handler<Promise<T>> action, boolean ordered)

Implements io.vertx.core.Context.executeBlocking.

Same as executeBlocking(Handler, boolean, Handler) but with an handler called when the operation completes

public final <T> Future<T>
executeBlocking(Callable<T>
handler representing the blocking code to run
blockingCodeHandler
,
boolean
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
ordered
)

Implements io.vertx.core.Context.executeBlocking.

Safely execute some blocking code.

public final <T> Future<T>
executeBlocking(Handler<Promise<T>> blockingCodeHandler, TaskQueue queue)

Implements io.vertx.core.impl.ContextInternal.executeBlocking.

Like executeBlocking(Handler, boolean) but uses the queue to order the tasks instead of the internal queue of this context.

public final <T> Future<T>
public final <T> Future<T>
public <T> Future<T>
public final <T> Future<T>
executeBlockingInternal(Handler<Promise<T>> action, boolean ordered)

Implements io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Like executeBlockingInternal(Handler, boolean, Handler) but returns a Future of the asynchronous result

public <T> Future<T>
public Executor
public final Deployment
public boolean
public boolean
isDuplicate()

Overrides default io.vertx.core.impl.ContextInternal.isDuplicate.

Returns true if this context is a duplicated context.

public boolean
isEventLoopContext()

Implements io.vertx.core.Context.isEventLoopContext.

Is the current context an event loop context?

public boolean
isWorkerContext()

Implements io.vertx.core.Context.isWorkerContext.

Is the current context a worker context?

public final EventLoop
nettyEventLoop()

Implements io.vertx.core.impl.ContextInternal.nettyEventLoop.

Return the Netty EventLoop used by this Context.

public final VertxInternal
public final void
reportException(Throwable
the exception to report
t
)

Implements io.vertx.core.impl.ContextInternal.reportException.

Report an exception to this context synchronously.

public ThreadingModel
public final VertxTracer<I, O>
public ContextInternal
unwrap()

Overrides default io.vertx.core.impl.ContextInternal.unwrap.

Returns the original context, a duplicate context returns the wrapped context otherwise this instance is returned.

public WorkerPool
Inherited from io.vertx.core.impl.ContextBase:
getLocalgetLocalputLocal

Field Detail

delegateback to summary
pack-priv final ContextImpl delegate

Constructor Detail

DuplicatedContextback to summary
pack-priv DuplicatedContext(ContextImpl delegate)

Method Detail

classLoaderback to summary
public final ClassLoader classLoader()

Implements io.vertx.core.impl.ContextInternal.classLoader.

Returns:ClassLoader

Doc from io.vertx.core.impl.ContextInternal.classLoader.

the classloader associated with this context

Annotations
@Override
closeback to summary
public Future<Void> close()

Implements io.vertx.core.impl.ContextInternal.close.

Doc from io.vertx.core.impl.ContextInternal.close.

Close this context, cleanup close future hooks then dispose pending ordered task queue.

Returns:Future<Void>

a future signalling close completion

Annotations
@Override
closeFutureback to summary
public final CloseFuture closeFuture()

Implements io.vertx.core.impl.ContextInternal.closeFuture.

Annotations
@Override
configback to summary
public final JsonObject config()

Implements io.vertx.core.Context.config.

Doc from io.vertx.core.Context.config.

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

If the context is associated with a Verticle deployment, this returns the configuration that was specified when the verticle was deployed.

Returns:JsonObject

the configuration of the deployment or null if not a Verticle deployment

Annotations
@Override
contextDataback to summary
public final ConcurrentMap<Object, Object> contextData()

Implements io.vertx.core.impl.ContextInternal.contextData.

Returns:ConcurrentMap<Object, Object>

Doc from io.vertx.core.impl.ContextInternal.contextData.

the ConcurrentMap used to store context data

Annotations
@Override
duplicateback to summary
public ContextInternal duplicate()

Implements io.vertx.core.impl.ContextInternal.duplicate.

Doc from io.vertx.core.impl.ContextInternal.duplicate.

Returns a context sharing with this context

  • the same concurrency
  • the same exception handler
  • the same context data
  • the same deployment
  • the same config
  • the same classloader

The duplicate context has its own

  • local context data
  • worker task queue
Returns:ContextInternal

a duplicate of this context

Annotations
@Override
emitback to summary
public <T> void emit(T argument, Handler<T> task)

Implements io.vertx.core.impl.ContextInternal.emit.

Doc from io.vertx.core.impl.ContextInternal.emit.

Emit the given argument event to the task and switch on this context if necessary, this also associates the current thread with the current context so Vertx#currentContext() returns this context.
Any exception thrown from the task will be reported on this context.
Calling this method is equivalent to execute(v -> dispatch(argument, task))

Parameters
argument:T

the task argument

task:Handler<T>

the handler to execute with the event argument

Annotations
@Override
exceptionHandlerback to summary
public final Context exceptionHandler(Handler<Throwable> handler)
Annotations
@Override
exceptionHandlerback to summary
public final Handler<Throwable> exceptionHandler()

Implements io.vertx.core.Context.exceptionHandler.

Returns:Handler<Throwable>

Doc from io.vertx.core.Context.exceptionHandler.

the current exception handler of this context

Annotations
@Override
executeback to summary
public final <T> void execute(T argument, Handler<T> task)

Implements io.vertx.core.impl.ContextInternal.execute.

Doc from io.vertx.core.impl.ContextInternal.execute.

Execute a task on this context, the task will be executed according to the context concurrency model.

Parameters
argument:T

the task argument

task:Handler<T>

the task to execute

Annotations
@Override
executeback to summary
public void execute(Runnable task)

Implements io.vertx.core.impl.ContextInternal.execute.

Doc from io.vertx.core.impl.ContextInternal.execute.

Execute the task on this context, it will be executed according to the context concurrency model.

Parameters
task:Runnable

the task to execute

Annotations
@Override
executeBlockingback to summary
public final <T> Future<T> executeBlocking(Handler<Promise<T>> action, boolean ordered)

Implements io.vertx.core.Context.executeBlocking.

Doc from io.vertx.core.Context.executeBlocking.

Same as executeBlocking(Handler, boolean, Handler) but with an handler called when the operation completes

Annotations
@Override
executeBlockingback to summary
public final <T> Future<T> executeBlocking(Callable<T> blockingCodeHandler, boolean ordered)

Implements io.vertx.core.Context.executeBlocking.

Doc from io.vertx.core.Context.executeBlocking.

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.

The blocking code should block for a reasonable amount of time (i.e no more than a few seconds). Long blocking operations or polling operations (i.e a thread that spin in a loop polling events in a blocking fashion) are precluded.

When the blocking operation lasts more than the 10 seconds, a message will be printed on the console by the blocked thread checker.

Long blocking operations should use a dedicated thread managed by the application, which can interact with verticles using the event-bus or Context#runOnContext(Handler)

Parameters
<T>
the type of the result
blockingCodeHandler:Callable<T>

handler representing the blocking code to run

ordered:boolean

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:Future<T>

a future completed when the blocking code is complete

Annotations
@Override
executeBlockingback to summary
public final <T> Future<T> executeBlocking(Handler<Promise<T>> blockingCodeHandler, TaskQueue queue)

Implements io.vertx.core.impl.ContextInternal.executeBlocking.

Doc from io.vertx.core.impl.ContextInternal.executeBlocking.

Like executeBlocking(Handler, boolean) but uses the queue to order the tasks instead of the internal queue of this context.

Annotations
@Override
executeBlockingback to summary
public final <T> Future<T> executeBlocking(Callable<T> blockingCodeHandler, TaskQueue queue)

Implements io.vertx.core.impl.ContextInternal.executeBlocking.

Annotations
@Override
executeBlockingInternalback to summary
public final <T> Future<T> executeBlockingInternal(Handler<Promise<T>> action)

Implements io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Doc from io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Like executeBlockingInternal(Handler, Handler) but returns a Future of the asynchronous result

Annotations
@Override
executeBlockingInternalback to summary
public <T> Future<T> executeBlockingInternal(Callable<T> action)

Implements io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Annotations
@Override
executeBlockingInternalback to summary
public final <T> Future<T> executeBlockingInternal(Handler<Promise<T>> action, boolean ordered)

Implements io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Doc from io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Like executeBlockingInternal(Handler, boolean, Handler) but returns a Future of the asynchronous result

Annotations
@Override
executeBlockingInternalback to summary
public <T> Future<T> executeBlockingInternal(Callable<T> action, boolean ordered)

Implements io.vertx.core.impl.ContextInternal.executeBlockingInternal.

Annotations
@Override
executorback to summary
public Executor executor()

Implements io.vertx.core.impl.ContextInternal.executor.

Returns:Executor

Doc from io.vertx.core.impl.ContextInternal.executor.

an executor that schedule a task on this context, the thread executing the task will not be associated with this context

Annotations
@Override
getDeploymentback to summary
public final Deployment getDeployment()

Implements io.vertx.core.impl.ContextInternal.getDeployment.

Returns:Deployment

Doc from io.vertx.core.impl.ContextInternal.getDeployment.

the deployment associated with this context or null

Annotations
@Override
inThreadback to summary
public boolean inThread()

Implements io.vertx.core.impl.ContextInternal.inThread.

Annotations
@Override
isDuplicateback to summary
public boolean isDuplicate()

Overrides default io.vertx.core.impl.ContextInternal.isDuplicate.

Doc from io.vertx.core.impl.ContextInternal.isDuplicate.

Returns true if this context is a duplicated context.

Returns:boolean

true if this context is a duplicated context, false otherwise.

Annotations
@Override
isEventLoopContextback to summary
public boolean isEventLoopContext()

Implements io.vertx.core.Context.isEventLoopContext.

Doc from io.vertx.core.Context.isEventLoopContext.

Is the current context an event loop context?

Note

when running blocking code using io.vertx.core.Vertx#executeBlocking(Callable) from a standard (not worker) verticle, the context will still an event loop context and this this#isEventLoopContext() will return true.

Returns:boolean

true if false otherwise

Annotations
@Override
isWorkerContextback to summary
public boolean isWorkerContext()

Implements io.vertx.core.Context.isWorkerContext.

Doc from io.vertx.core.Context.isWorkerContext.

Is the current context a worker context?

Note

when running blocking code using io.vertx.core.Vertx#executeBlocking(Callable) from a standard (not worker) verticle, the context will still an event loop context and this this#isWorkerContext() will return false.

Returns:boolean

true if the current context is a worker context, false otherwise

Annotations
@Override
nettyEventLoopback to summary
public final EventLoop nettyEventLoop()

Implements io.vertx.core.impl.ContextInternal.nettyEventLoop.

Doc from io.vertx.core.impl.ContextInternal.nettyEventLoop.

Return the Netty EventLoop used by this Context. This can be used to integrate a Netty Server with a Vert.x runtime, specially the Context part.

Returns:EventLoop

the EventLoop

Annotations
@Override
ownerback to summary
public final VertxInternal owner()

Implements io.vertx.core.impl.ContextInternal.owner.

Returns:VertxInternal

Doc from io.vertx.core.Context.owner.

The Vertx instance that created the context

Annotations
@Override
reportExceptionback to summary
public final void reportException(Throwable t)

Implements io.vertx.core.impl.ContextInternal.reportException.

Doc from io.vertx.core.impl.ContextInternal.reportException.

Report an exception to this context synchronously.

The exception handler will be called when there is one, otherwise the exception will be logged.

Parameters
t:Throwable

the exception to report

Annotations
@Override
threadingModelback to summary
public ThreadingModel threadingModel()

Implements io.vertx.core.Context.threadingModel.

Returns:ThreadingModel

Doc from io.vertx.core.Context.threadingModel.

the context threading model

Annotations
@Override
tracerback to summary
public final VertxTracer<I, O> tracer()

Implements io.vertx.core.impl.ContextInternal.tracer.

Returns:VertxTracer<I, O>

Doc from io.vertx.core.impl.ContextInternal.tracer.

the tracer for this context

Annotations
@Override
unwrapback to summary
public ContextInternal unwrap()

Overrides default io.vertx.core.impl.ContextInternal.unwrap.

Doc from io.vertx.core.impl.ContextInternal.unwrap.

Returns the original context, a duplicate context returns the wrapped context otherwise this instance is returned.

Returns:ContextInternal

the wrapped context

Annotations
@Override
workerPoolback to summary
public WorkerPool workerPool()

Implements io.vertx.core.impl.ContextInternal.workerPool.

Returns:WorkerPool

Doc from io.vertx.core.impl.ContextInternal.workerPool.

the context worker pool

Annotations
@Override