OrderedEventExecutor's implementation that execute all its submitted tasks in a single thread.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| protected static final int | |
| private final Executor | |
| private volatile long | |
| private long | |
| private volatile long | |
| private volatile boolean | |
| private long | |
| private static final InternalLogger | |
| private static final Runnable | |
| private static final AtomicReferenceFieldUpdater | |
| private final RejectedExecutionHandler | |
| private static final long | |
| private final Set | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private volatile int | |
| private static final AtomicIntegerFieldUpdater | |
| private final Queue | |
| private final Promise | |
| private volatile Thread | |
| private final CountDownLatch | |
| private volatile ThreadProperties | |
| private static final Runnable |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SingleThreadEventExecutor(ThreadFactory
the threadFactory)ThreadFactory which will be used for the used ThreadCreate a new instance |
| public | SingleThreadEventExecutor(ThreadFactory
the threadFactory, int ThreadFactory which will be used for the used Threadthe maximum number of pending tasks before new tasks will be rejected. maxPendingTasks, RejectedExecutionHandler the rejectedHandler)RejectedExecutionHandler to use.Create a new instance |
| public | SingleThreadEventExecutor(Executor
the executor)Executor which will be used for executingCreate a new instance |
| public | SingleThreadEventExecutor(Executor
the executor, int Executor which will be used for executingthe maximum number of pending tasks before new tasks will be rejected. maxPendingTasks, RejectedExecutionHandler the rejectedHandler)RejectedExecutionHandler to use.Create a new instance |
| Modifier and Type | Method and Description |
|---|---|
| public final void | addShutdownHook(final Runnable task)
Add a |
| private void | addTask(Runnable task)
Add a task to the task queue, or throws a |
| public final boolean | awaitTermination(long
The non-negative maximum amount of time to wait for the executor group to terminate. timeout, TimeUnit The non-null time unit of the timeout. unit)Overrides default io. EventExecutorGroup to terminate, up to the given timeout.
|
| protected void | |
| protected final boolean | |
| pack-priv boolean | |
| protected final long | deadlineNanos()
Returns the absolute point in time (relative to |
| protected final long | delayNanos(long currentTimeNanos)
Returns the amount of time left until the scheduled task with the closest dead line is executed. |
| private void | |
| pack-priv final int | |
| private boolean | |
| public void | execute(Runnable
the runnable task task)Implements io. |
| private boolean | |
| protected final boolean | |
| public final boolean | inEventLoop(Thread thread)
Implements io. true if the given Thread is executed in the event loop,
false otherwise.
|
| protected final void | |
| public final boolean | isShutdown()
Implements io. true if all EventExecutors managed by this EventExecutorGroup have been
shut down gracefully and moved past the grace period so that they are no
longer accepting any new tasks.
|
| public final boolean | isShuttingDown()
Implements io. true if and only if all EventExecutors managed by this EventExecutorGroup
are being shut down gracefully or was shut down.
|
| public final boolean | isTerminated()
Overrides default io. true if all EventExecutors managed by this EventExecutorGroup are
shut down, and all of their tasks have completed.
|
| protected Queue | |
| protected final boolean | |
| public final int | pendingTasks()
Return the number of tasks that are pending for processing (excluding the scheduled tasks). |
| protected final Runnable | |
| protected static void | |
| public final void | |
| protected final boolean | |
| protected void | |
| private boolean | Returns: true if and only if at least one task was runPoll all tasks from the task queue and run them via |
| protected int | Returns: the number of processed tasks.Poll all tasks from the task queue and run them via |
| private boolean | |
| private void | |
| public final Future | shutdownGracefully(long
the quiet period as described in the documentation quietPeriod, long the maximum amount of time to wait until the executor is
shutting down regardless if a task was submitted during the quiet period. timeout, TimeUnit the unit of unit)quietPeriod and timeoutImplements io. |
| private void | |
| protected final Runnable | |
| public final Future | terminationFuture()
Implements io. Future which is notified when all EventExecutors managed by this
EventExecutorGroup have been terminated.
|
| public final ThreadProperties | threadProperties()
Returns the |
| protected final void | updateLastExecutionTime()
Updates the internal timestamp that tells when a submitted task was executed most recently. |
| protected boolean | wakesUpForTask(Runnable task)
Returns |
| protected void |
| addTaskWakesUp | back to summary |
|---|---|
| private final boolean addTaskWakesUp | |
| DEFAULT_MAX_PENDING_EXECUTOR_TASKS | back to summary |
|---|---|
| protected static final int DEFAULT_MAX_PENDING_EXECUTOR_TASKS | |
| executor | back to summary |
|---|---|
| private final Executor executor | |
| gracefulShutdownQuietPeriod | back to summary |
|---|---|
| private volatile long gracefulShutdownQuietPeriod | |
| gracefulShutdownStartTime | back to summary |
|---|---|
| private long gracefulShutdownStartTime | |
| gracefulShutdownTimeout | back to summary |
|---|---|
| private volatile long gracefulShutdownTimeout | |
| interrupted | back to summary |
|---|---|
| private volatile boolean interrupted | |
| lastExecutionTime | back to summary |
|---|---|
| private long lastExecutionTime | |
| logger | back to summary |
|---|---|
| private static final InternalLogger logger Hides io. | |
| NOOP_TASK | back to summary |
|---|---|
| private static final Runnable NOOP_TASK | |
| PROPERTIES_UPDATER | back to summary |
|---|---|
| private static final AtomicReferenceFieldUpdater<SingleThreadEventExecutor, ThreadProperties> PROPERTIES_UPDATER | |
| rejectedExecutionHandler | back to summary |
|---|---|
| private final RejectedExecutionHandler rejectedExecutionHandler | |
| SCHEDULE_PURGE_INTERVAL | back to summary |
|---|---|
| private static final long SCHEDULE_PURGE_INTERVAL | |
| shutdownHooks | back to summary |
|---|---|
| private final Set<Runnable> shutdownHooks | |
| ST_NOT_STARTED | back to summary |
|---|---|
| private static final int ST_NOT_STARTED | |
| ST_SHUTDOWN | back to summary |
|---|---|
| private static final int ST_SHUTDOWN | |
| ST_SHUTTING_DOWN | back to summary |
|---|---|
| private static final int ST_SHUTTING_DOWN | |
| ST_STARTED | back to summary |
|---|---|
| private static final int ST_STARTED | |
| ST_TERMINATED | back to summary |
|---|---|
| private static final int ST_TERMINATED | |
| state | back to summary |
|---|---|
private volatile int state
| |
| STATE_UPDATER | back to summary |
|---|---|
| private static final AtomicIntegerFieldUpdater<SingleThreadEventExecutor> STATE_UPDATER | |
| taskQueue | back to summary |
|---|---|
| private final Queue<Runnable> taskQueue | |
| terminationFuture | back to summary |
|---|---|
| private final Promise<Void> terminationFuture | |
| thread | back to summary |
|---|---|
| private volatile Thread thread | |
| threadLock | back to summary |
|---|---|
| private final CountDownLatch threadLock | |
| threadProperties | back to summary |
|---|---|
private volatile ThreadProperties threadProperties
| |
| WAKEUP_TASK | back to summary |
|---|---|
| private static final Runnable WAKEUP_TASK | |
| SingleThreadEventExecutor | back to summary |
|---|---|
| public SingleThreadEventExecutor() Create a new instance | |
| SingleThreadEventExecutor | back to summary |
|---|---|
| public SingleThreadEventExecutor(ThreadFactory threadFactory) Create a new instance
| |
| SingleThreadEventExecutor | back to summary |
|---|---|
| public SingleThreadEventExecutor(ThreadFactory threadFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler) Create a new instance
| |
| SingleThreadEventExecutor | back to summary |
|---|---|
| public SingleThreadEventExecutor(Executor executor) Create a new instance | |
| SingleThreadEventExecutor | back to summary |
|---|---|
| public SingleThreadEventExecutor(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedHandler) Create a new instance
| |
| addShutdownHook | back to summary |
|---|---|
| public final void addShutdownHook(final Runnable task) Add a | |
| addTask | back to summary |
|---|---|
| private void addTask(Runnable task) Add a task to the task queue, or throws a | |
| awaitTermination | back to summary |
|---|---|
| public final boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException Overrides default io. Doc from io. Wait for this
| |
| cleanup | back to summary |
|---|---|
| protected void cleanup() Do nothing, sub-classes may override. | |
| confirmShutdown | back to summary |
|---|---|
| protected final boolean confirmShutdown() Confirm that the shutdown if the instance should be done now!
This method must be called from the | |
| confirmShutdown0 | back to summary |
|---|---|
| pack-priv boolean confirmShutdown0() | |
| deadlineNanos | back to summary |
|---|---|
| protected final long deadlineNanos() Returns the absolute point in time (relative to | |
| delayNanos | back to summary |
|---|---|
| protected final long delayNanos(long currentTimeNanos) Returns the amount of time left until the scheduled task with the closest dead line is executed.
This method must be called from the | |
| doStartThread | back to summary |
|---|---|
| private void doStartThread() | |
| drainTasks | back to summary |
|---|---|
| pack-priv final int drainTasks() | |
| ensureThreadStarted | back to summary |
|---|---|
| private boolean ensureThreadStarted(int oldState) | |
| execute | back to summary |
|---|---|
| public void execute(Runnable task) Implements io. Doc from java. 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 | |
| fetchFromScheduledTaskQueue | back to summary |
|---|---|
| private boolean fetchFromScheduledTaskQueue() | |
| hasTasks | back to summary |
|---|---|
protected final boolean hasTasks()
| |
| inEventLoop | back to summary |
|---|---|
| public final boolean inEventLoop(Thread thread) Implements io. Doc from io. Return
| |
| interruptThread | back to summary |
|---|---|
| protected final void interruptThread() Interrupt the current running | |
| isShutdown | back to summary |
|---|---|
| public final boolean isShutdown() Implements io. Doc from io. Returns An executor group that "is shut down" might still be executing tasks that it has queued up, but it will no longer be accepting any new tasks. Once all running and queued tasks have completed, the executor group will be terminated.
| |
| isShuttingDown | back to summary |
|---|---|
| public final boolean isShuttingDown() Implements io. Doc from io. Returns An executor group that "is shutting down" can still accept new tasks for a little while (the grace period), but will eventually start rejecting new tasks. At that point, the executor group will be shut down.
| |
| isTerminated | back to summary |
|---|---|
| public final boolean isTerminated() Overrides default io. Doc from io. Returns
| |
| newTaskQueue | back to summary |
|---|---|
| protected Queue Create a new | |
| offerTask | back to summary |
|---|---|
protected final boolean offerTask(Runnable task)
| |
| pendingTasks | back to summary |
|---|---|
| public final int pendingTasks() Return the number of tasks that are pending for processing (excluding the scheduled tasks). | |
| pollTask | back to summary |
|---|---|
| protected final Runnable pollTask() | |
| reject | back to summary |
|---|---|
| protected static void reject() | |
| removeShutdownHook | back to summary |
|---|---|
| public final void removeShutdownHook(final Runnable task) Remove a previous added | |
| removeTask | back to summary |
|---|---|
protected final boolean removeTask(Runnable task)
| |
| run | back to summary |
|---|---|
| protected void run() Run tasks that are submitted to this | |
| runAllTasks | back to summary |
|---|---|
| private boolean runAllTasks() Poll all tasks from the task queue and run them via
| |
| runAllTasks | back to summary |
|---|---|
| protected int runAllTasks(int maxTasks) Poll all tasks from the task queue and run them via
| |
| runShutdownHooks | back to summary |
|---|---|
| private boolean runShutdownHooks() | |
| runTask | back to summary |
|---|---|
| private void runTask(Runnable task) | |
| shutdownGracefully | back to summary |
|---|---|
| public final Future Implements io. Doc from io. Signals this executor that the caller wants the executor to be shut down. Once this method is called,
| |
| startThread | back to summary |
|---|---|
| private void startThread() | |
| takeTask | back to summary |
|---|---|
| protected final Runnable takeTask() Take the next
Be aware that this method will throw an EventExecutor thread.
| |
| terminationFuture | back to summary |
|---|---|
| public final Future Implements io. Doc from io. Returns the
| |
| threadProperties | back to summary |
|---|---|
| public final ThreadProperties threadProperties() throws InterruptedException Returns the
| |
| updateLastExecutionTime | back to summary |
|---|---|
| protected final void updateLastExecutionTime() Updates the internal timestamp that tells when a submitted task was executed most recently.
| |
| wakesUpForTask | back to summary |
|---|---|
| protected boolean wakesUpForTask(Runnable task) Returns | |
| wakeup | back to summary |
|---|---|
| protected void wakeup(boolean inEventLoop) | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public boolean | |
| public boolean | |
| public boolean | |
| public String | |
| public int | |
| public StackTraceElement[] | |
| public Thread. |
| t | back to summary |
|---|---|
| private final Thread t | |
| DefaultThreadProperties | back to summary |
|---|---|
| pack-priv DefaultThreadProperties(Thread t) | |
| id | back to summary |
|---|---|
| public long id() Implements io.
| |
| isAlive | back to summary |
|---|---|
| public boolean isAlive() Implements io.
| |
| isDaemon | back to summary |
|---|---|
| public boolean isDaemon() Implements io.
| |
| isInterrupted | back to summary |
|---|---|
| public boolean isInterrupted() Implements io.
| |
| name | back to summary |
|---|---|
| public String name() Implements io.
| |
| priority | back to summary |
|---|---|
| public int priority() Implements io.
| |
| stackTrace | back to summary |
|---|---|
| public StackTraceElement[] stackTrace() Implements io.
| |
| state | back to summary |
|---|---|
| public Thread. Implements io.
| |