EventExecutor. It starts the thread automatically and stops it when there is no
task pending in the task queue for 1 second. Please note it is not scalable to schedule large number of tasks to
this executor; use a dedicated executor.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| public static final GlobalEventExecutor | |
| private static final InternalLogger | |
| private final RunnableScheduledFutureAdapter | |
| private static final long | |
| private final AtomicBoolean | |
| private final BlockingQueue | |
| private final GlobalEventExecutor. | |
| private final Future | |
| pack-priv volatile Thread | |
| pack-priv final ThreadFactory |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private void | addTask(Runnable task)
Add a task to the task queue, or throws a |
| public boolean | Returns: true if and only if the worker thread has been terminatedWaits until the worker thread of this executor has no tasks left in its task queue and terminates itself. |
| public 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.
|
| public void | execute(Runnable
the runnable task task)Implements io. |
| private void | |
| public boolean | inEventLoop(Thread thread)
Implements io. true if the given Thread is executed in the event loop,
false otherwise.
|
| public 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 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 boolean | isTerminated()
Overrides default io. true if all EventExecutors managed by this EventExecutorGroup are
shut down, and all of their tasks have completed.
|
| public int | |
| public 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 | |
| private Runnable | |
| public Future | terminationFuture()
Implements io. Future which is notified when all EventExecutors managed by this
EventExecutorGroup have been terminated.
|
| INSTANCE | back to summary |
|---|---|
| public static final GlobalEventExecutor INSTANCE | |
| logger | back to summary |
|---|---|
| private static final InternalLogger logger Hides io. | |
| quietPeriodTask | back to summary |
|---|---|
| private final RunnableScheduledFutureAdapter<Void> quietPeriodTask | |
| SCHEDULE_QUIET_PERIOD_INTERVAL | back to summary |
|---|---|
| private static final long SCHEDULE_QUIET_PERIOD_INTERVAL | |
| started | back to summary |
|---|---|
| private final AtomicBoolean started | |
| taskQueue | back to summary |
|---|---|
| private final BlockingQueue<Runnable> taskQueue | |
| taskRunner | back to summary |
|---|---|
| private final GlobalEventExecutor. | |
| terminationFuture | back to summary |
|---|---|
| private final Future<Void> terminationFuture | |
| thread | back to summary |
|---|---|
| pack-priv volatile Thread thread | |
| threadFactory | back to summary |
|---|---|
| pack-priv final ThreadFactory threadFactory | |
| GlobalEventExecutor | back to summary |
|---|---|
| private GlobalEventExecutor() | |
| addTask | back to summary |
|---|---|
| private void addTask(Runnable task) Add a task to the task queue, or throws a | |
| awaitInactivity | back to summary |
|---|---|
| public boolean awaitInactivity(long timeout, TimeUnit unit) throws InterruptedException Waits until the worker thread of this executor has no tasks left in its task queue and terminates itself. Because a new worker thread will be started again when a new task is submitted, this operation is only useful when you want to ensure that the worker thread is terminated after your application is shut down and there's no chance of submitting a new task afterwards.
| |
| awaitTermination | back to summary |
|---|---|
| public boolean awaitTermination(long timeout, TimeUnit unit) Overrides default io. Doc from io. Wait for this | |
| 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 void fetchFromScheduledTaskQueue() | |
| inEventLoop | back to summary |
|---|---|
| public boolean inEventLoop(Thread thread) Implements io. Doc from io. Return
| |
| isShutdown | back to summary |
|---|---|
| public 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 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 boolean isTerminated() Overrides default io. Doc from io. Returns
| |
| pendingTasks | back to summary |
|---|---|
| public int pendingTasks() Return the number of tasks that are pending for processing. | |
| shutdownGracefully | back to summary |
|---|---|
| public 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 |
|---|---|
| private Runnable takeTask() Take the next
| |
| terminationFuture | back to summary |
|---|---|
| public Future Implements io. Doc from io. Returns the
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void |
| TaskRunner | back to summary |
|---|---|
| pack-priv TaskRunner() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| runTask | back to summary |
|---|---|
| private void runTask(Runnable task) | |