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

public Class WorkerExecutor

extends Object
implements EventExecutor
Class Inheritance
All Implemented Interfaces
io.vertx.core.impl.EventExecutor, java.util.concurrent.Executor
Imports
io.vertx.core.Future, .ThreadingModel, .Vertx, io.vertx.core.spi.metrics.PoolMetrics, java.util.concurrent.CountDownLatch, .Executor, .TimeUnit, java.util.function.Consumer

Execute events on a worker pool.
Author
Julien Viet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private final ThreadLocal<Boolean>
private final WorkerTaskQueue
private final WorkerPool

Constructor Summary

AccessConstructor and Description
public
WorkerExecutor(WorkerPool workerPool, WorkerTaskQueue orderedTasks)

Method Summary

Modifier and TypeMethod and Description
public void
execute(Runnable
the runnable task
command
)

Implements java.util.concurrent.Executor.execute.

Executes the given command at some time in the future.

public boolean
public CountDownLatch

Returns:

the latch to wait for until the current task can resume
suspend
(Consumer<WorkerExecutor.Continuation> resumeAcceptor)

Suspend the current task execution until the task is resumed, the next task in the queue will be executed when there is one.

pack-priv WorkerTaskQueue
public static WorkerExecutor
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

inThreadback to summary
private final ThreadLocal<Boolean> inThread
orderedTasksback to summary
private final WorkerTaskQueue orderedTasks
workerPoolback to summary
private final WorkerPool workerPool

Constructor Detail

WorkerExecutorback to summary
public WorkerExecutor(WorkerPool workerPool, WorkerTaskQueue orderedTasks)

Method Detail

executeback to summary
public void execute(Runnable command)

Implements java.util.concurrent.Executor.execute.

Doc from java.util.concurrent.Executor.execute.

Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

Parameters
command:Runnable

the runnable task

Annotations
@Override
inThreadback to summary
public boolean inThread()

Implements io.vertx.core.impl.EventExecutor.inThread.

Returns:boolean

Doc from io.vertx.core.impl.EventExecutor.inThread.

whether the current thread is one of the event executor thread

Annotations
@Override
suspendback to summary
public CountDownLatch suspend(Consumer<WorkerExecutor.Continuation> resumeAcceptor)

Suspend the current task execution until the task is resumed, the next task in the queue will be executed when there is one.

The resumeAcceptor argument is passed the continuation to resume the current task, this acceptor is guaranteed to be called before the task is actually suspended so the task can be eagerly resumed and avoid suspending the current task.

Returns:CountDownLatch

the latch to wait for until the current task can resume

taskQueueback to summary
pack-priv WorkerTaskQueue taskQueue()
unwrapWorkerExecutorback to summary
public static WorkerExecutor unwrapWorkerExecutor()
io.vertx.core.impl back to summary

public Interface WorkerExecutor.Continuation

Known Direct Implementers
io.vertx.core.impl.TaskQueue.ContinuationTask

Method Summary

Modifier and TypeMethod and Description
public void
resume(Runnable
called when the task is resumed
callback
)

Resume the task, the callback will be executed when the task is resumed, before the task thread is un-parked.

public default void

Method Detail

resumeback to summary
public void resume(Runnable callback)

Resume the task, the callback will be executed when the task is resumed, before the task thread is un-parked.

Parameters
callback:Runnable

called when the task is resumed

resumeback to summary
public default void resume()

Like resume(Runnable).