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

public Class TaskQueue

extends Object
Class Inheritance
Known Direct Subclasses
io.vertx.core.impl.WorkerTaskQueue
Imports
io.vertx.core.impl.logging.Logger, .LoggerFactory, java.util.*, java.util.concurrent.CountDownLatch, .Executor, .RejectedExecutionException, java.util.function.Consumer

A task queue that always run all tasks in order. The executor to run the tasks is passed when the tasks are executed, this executor is not guaranteed to be used, as if several tasks are queued, the original thread will be used. More specifically, any call B to the execute(Runnable, Executor) method that happens-after another call A to the same method, will result in B's task running after A's.
Authors
David Lloyd, Tim Fox, Julien Viet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
TaskQueue.CloseResult

Structure holding the queue state at close time.

private class
private static class
TaskQueue.ExecuteTask

Execute another task

private static interface
TaskQueue.Task

A task of this queue.

Field Summary

Modifier and TypeField and Description
private boolean
private final Set<TaskQueue.ContinuationTask>
private Executor
private TaskQueue.ExecuteTask
private Thread
pack-priv static final Logger
private final Runnable
private final LinkedList<TaskQueue.Task>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public TaskQueue.CloseResult

Returns:

a structure of suspended threads and pending tasks
close
()

Close the queue.

private TaskQueue.ContinuationTask

Returns:

the controller
continuationTask
()

Return a continuation task for the current task execution.

public void
execute(Runnable
the task to run.
task
,
Executor executor)

Run a task.

public boolean
isEmpty()

Test if the task queue is empty and no current executor is running anymore.

private void
run()

public CountDownLatch
public CountDownLatch
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private boolean closed
continuationsback to summary
private final Set<TaskQueue.ContinuationTask> continuations
currentExecutorback to summary
private Executor currentExecutor
currentTaskback to summary
private TaskQueue.ExecuteTask currentTask
currentThreadback to summary
private Thread currentThread
logback to summary
pack-priv static final Logger log
runnerback to summary
private final Runnable runner
tasksback to summary
private final LinkedList<TaskQueue.Task> tasks

Constructor Detail

TaskQueueback to summary
public TaskQueue()

Method Detail

closeback to summary
public TaskQueue.CloseResult close()

Close the queue.

Returns:TaskQueue.CloseResult

a structure of suspended threads and pending tasks

continuationTaskback to summary
private TaskQueue.ContinuationTask continuationTask()

Return a continuation task for the current task execution.

Returns:TaskQueue.ContinuationTask

the controller

Exceptions
IllegalStateException:
if the current thread is not currently being executed by the queue
executeback to summary
public void execute(Runnable task, Executor executor) throws RejectedExecutionException

Run a task.

Parameters
task:Runnable

the task to run.

isEmptyback to summary
public boolean isEmpty()

Test if the task queue is empty and no current executor is running anymore.

runback to summary
private void run()
suspendback to summary
public CountDownLatch suspend()
suspendback to summary
public CountDownLatch suspend(Consumer<WorkerExecutor.Continuation> abc)
io.vertx.core.impl back to summary

public final Class TaskQueue.CloseResult

extends Object
Class Inheritance

Structure holding the queue state at close time.

Field Summary

Modifier and TypeField and Description
private final Runnable
private final Thread
private final List<Runnable>
private final List<Thread>

Constructor Summary

AccessConstructor and Description
private
CloseResult(Thread activeThread, Runnable activeTask, List<Thread> suspendedThreads, List<Runnable> suspendedTasks)

Method Summary

Modifier and TypeMethod and Description
public Runnable
public Thread

Returns:

the thread that was active
activeThread
()

public List<Runnable>

Returns:

the list of suspended tasks
suspendedTasks
()

public List<Thread>

Returns:

the list of suspended threads
suspendedThreads
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeTaskback to summary
private final Runnable activeTask
activeThreadback to summary
private final Thread activeThread
suspendedTasksback to summary
private final List<Runnable> suspendedTasks
suspendedThreadsback to summary
private final List<Thread> suspendedThreads

Constructor Detail

CloseResultback to summary
private CloseResult(Thread activeThread, Runnable activeTask, List<Thread> suspendedThreads, List<Runnable> suspendedTasks)

Method Detail

activeTaskback to summary
public Runnable activeTask()
activeThreadback to summary
public Thread activeThread()
Returns:Thread

the thread that was active

suspendedTasksback to summary
public List<Runnable> suspendedTasks()
Returns:List<Runnable>

the list of suspended tasks

suspendedThreadsback to summary
public List<Thread> suspendedThreads()
Returns:List<Thread>

the list of suspended threads

io.vertx.core.impl back to summary

private Class TaskQueue.ContinuationTask

extends CountDownLatch
implements Continuation, Task
Class Inheritance
All Implemented Interfaces
io.vertx.core.impl.TaskQueue.Task, io.vertx.core.impl.WorkerExecutor.Continuation

Field Summary

Modifier and TypeField and Description
private final Executor
private Runnable
private static final int
private static final int
private static final int
private int
private final TaskQueue.ExecuteTask
private final Thread

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

Implements io.vertx.core.impl.WorkerExecutor.Continuation.resume.

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

public boolean
Inherited from java.util.concurrent.CountDownLatch:
awaitawaitcountDowngetCounttoString

Field Detail

executorback to summary
private final Executor executor
latchback to summary
private Runnable latch
ST_CREATEDback to summary
private static final int ST_CREATED
ST_RESUMEDback to summary
private static final int ST_RESUMED
ST_SUSPENDEDback to summary
private static final int ST_SUSPENDED
statusback to summary
private int status
taskback to summary
private final TaskQueue.ExecuteTask task
threadback to summary
private final Thread thread

Constructor Detail

ContinuationTaskback to summary
public ContinuationTask(TaskQueue.ExecuteTask task, Thread thread, Executor executor)

Method Detail

resumeback to summary
public void resume(Runnable callback)

Implements io.vertx.core.impl.WorkerExecutor.Continuation.resume.

Doc from io.vertx.core.impl.WorkerExecutor.Continuation.resume.

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

Annotations
@Override
suspendback to summary
public boolean suspend()
io.vertx.core.impl back to summary

private Class TaskQueue.ExecuteTask

extends Object
implements Task
Class Inheritance
All Implemented Interfaces
io.vertx.core.impl.TaskQueue.Task

Execute another task

Field Summary

Modifier and TypeField and Description
private final Executor
private final Runnable

Constructor Summary

AccessConstructor and Description
public
ExecuteTask(Runnable runnable, Executor exec)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

execback to summary
private final Executor exec
runnableback to summary
private final Runnable runnable

Constructor Detail

ExecuteTaskback to summary
public ExecuteTask(Runnable runnable, Executor exec)
io.vertx.core.impl back to summary

private Interface TaskQueue.Task

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

A task of this queue.