Top Description Inners Fields Constructors Methods
io.netty5.util.concurrent

public final Class ImmediateEventExecutor

extends AbstractEventExecutor
Class Inheritance
Imports
io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.ArrayDeque, .Queue, java.util.concurrent.Callable, .TimeUnit

Executes Runnable objects in the caller's thread. If the execute(Runnable) is reentrant it will be queued until the original Runnable finishes execution.

All Throwable objects thrown from execute(Runnable) will be swallowed and logged. This is to ensure that all queued Runnable objects have the chance to be run.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final FastThreadLocal<Queue<Runnable>>
DELAYED_RUNNABLES

A Runnable will be queued if we are executing a Runnable.

public static final ImmediateEventExecutor
private static final InternalLogger
private static final FastThreadLocal<Boolean>
RUNNING

Set to true if we are executing a runnable.

private final Future<Void>
Inherited from io.netty5.util.concurrent.AbstractEventExecutor:
DEFAULT_SHUTDOWN_QUIET_PERIODDEFAULT_SHUTDOWN_TIMEOUT

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
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.netty5.util.concurrent.EventExecutorGroup.awaitTermination.

Wait for this EventExecutorGroup to terminate, up to the given timeout.
public void
execute(Runnable
the runnable task
task
)

Implements io.netty5.util.concurrent.EventExecutor.execute.

Executes the given command at some time in the future.
public boolean
inEventLoop(Thread thread)

Implements io.netty5.util.concurrent.EventExecutor.inEventLoop.

Return true if the given Thread is executed in the event loop, false otherwise.
public boolean
isShutdown()

Implements io.netty5.util.concurrent.EventExecutorGroup.isShutdown.

Returns 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
public boolean
isTerminated()

Overrides default io.netty5.util.concurrent.EventExecutorGroup.isTerminated.

Returns true if all EventExecutors managed by this EventExecutorGroup are shut down, and all of their tasks have completed.
public <V> Promise<V>
public Future<Void>
schedule(Runnable
The task that should be executed in this EventExecutorGroup after the given delay.
task
,
long
A positive time delay, in the given time unit.
delay
,
TimeUnit
The non-null time unit for the delay.
unit
)

Implements io.netty5.util.concurrent.EventExecutor.schedule.

Schedule the given task for execution after the given delay, in the next available EventExecutor in this group, and return a future that produces a null result when the task completes.
public <V> Future<V>
schedule(Callable<V>
The task that should be executed in this EventExecutorGroup after the given delay.
task
,
long
A positive time delay, in the given time unit.
delay
,
TimeUnit
The non-null time unit for the delay.
unit
)

Implements io.netty5.util.concurrent.EventExecutor.schedule.

Schedule the given task for execution after the given delay, in the next available EventExecutor in this group, and return a future that will return the result of the callable when the task completes.
public Future<Void>
scheduleAtFixedRate(Runnable
The task that should be scheduled to execute at a fixed rate in this EventExecutorGroup.
task
,
long
The positive initial delay for the first task execution, in terms of the given time unit.
initialDelay
,
long
The positive period for the execution frequency to use after the first execution has started, in terms of the given time unit.
period
,
TimeUnit
The non-null time unit for the delay and period.
unit
)

Implements io.netty5.util.concurrent.EventExecutor.scheduleAtFixedRate.

Schedule the given task for periodic execution in the next available EventExecutor.
public Future<Void>
scheduleWithFixedDelay(Runnable
The task that should be scheduled to execute with fixed delays in this EventExecutorGroup.
task
,
long
The positive initial delay for the first task execution, in terms of the given time unit.
initialDelay
,
long
The positive subsequent delay between task, to use after the first execution has completed, in terms of the given time unit.
delay
,
TimeUnit
The non-null time unit for the delays.
unit
)

Implements io.netty5.util.concurrent.EventExecutor.scheduleWithFixedDelay.

Schedule the given task for periodic execution in the next available EventExecutor.
public Future<Void>
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 quietPeriod and timeout
unit
)

Implements io.netty5.util.concurrent.EventExecutorGroup.shutdownGracefully.

Signals this executor that the caller wants the executor to be shut down.
public Future<Void>
terminationFuture()

Implements io.netty5.util.concurrent.EventExecutorGroup.terminationFuture.

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.
Inherited from io.netty5.util.concurrent.AbstractEventExecutor:
newSucceededFuturenewTaskFornewTaskForsafeExecutesubmitsubmitsubmit

Field Detail

DELAYED_RUNNABLESback to summary
private static final FastThreadLocal<Queue<Runnable>> DELAYED_RUNNABLES

A Runnable will be queued if we are executing a Runnable. This is to prevent a StackOverflowError.

INSTANCEback to summary
public static final ImmediateEventExecutor INSTANCE
loggerback to summary
private static final InternalLogger logger

Hides io.netty5.util.concurrent.AbstractEventExecutor.logger.

RUNNINGback to summary
private static final FastThreadLocal<Boolean> RUNNING

Set to true if we are executing a runnable.

terminationFutureback to summary
private final Future<Void> terminationFuture

Constructor Detail

ImmediateEventExecutorback to summary
private ImmediateEventExecutor()

Method Detail

awaitTerminationback to summary
public boolean awaitTermination(long timeout, TimeUnit unit)

Overrides default io.netty5.util.concurrent.EventExecutorGroup.awaitTermination.

Doc from io.netty5.util.concurrent.EventExecutorGroup.awaitTermination.

Wait for this EventExecutorGroup to terminate, up to the given timeout.

Parameters
timeout:long

The non-negative maximum amount of time to wait for the executor group to terminate.

unit:TimeUnit

The non-null time unit of the timeout.

Returns:boolean

true if the executor group terminated within the specific timeout.

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

Implements io.netty5.util.concurrent.EventExecutor.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
task:Runnable

the runnable task

Annotations
@Override
inEventLoopback to summary
public boolean inEventLoop(Thread thread)

Implements io.netty5.util.concurrent.EventExecutor.inEventLoop.

Doc from io.netty5.util.concurrent.EventExecutor.inEventLoop.

Return true if the given Thread is executed in the event loop, false otherwise.

Annotations
@Override
isShutdownback to summary
public boolean isShutdown()

Implements io.netty5.util.concurrent.EventExecutorGroup.isShutdown.

Doc from io.netty5.util.concurrent.EventExecutorGroup.isShutdown.

Returns 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.

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.

Returns:boolean

true if all executors in this group have shut down and are no longer accepting any new tasks.

Annotations
@Override
isShuttingDownback to summary
public boolean isShuttingDown()

Implements io.netty5.util.concurrent.EventExecutorGroup.isShuttingDown.

Doc from io.netty5.util.concurrent.EventExecutorGroup.isShuttingDown.

Returns true if and only if all EventExecutors managed by this EventExecutorGroup are being shut down gracefully or was shut down.

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.

Returns:boolean

true if all executors in this group have at least started shutting down, otherwise false.

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Overrides default io.netty5.util.concurrent.EventExecutorGroup.isTerminated.

Doc from io.netty5.util.concurrent.EventExecutorGroup.isTerminated.

Returns true if all EventExecutors managed by this EventExecutorGroup are shut down, and all of their tasks have completed.

Returns:boolean

true if all executors in this group have terminated.

Annotations
@Override
newPromiseback to summary
public <V> Promise<V> newPromise()

Overrides default io.netty5.util.concurrent.EventExecutor.newPromise.

Doc from io.netty5.util.concurrent.EventExecutor.newPromise.

Return a new Promise.

Annotations
@Override
scheduleback to summary
public Future<Void> schedule(Runnable task, long delay, TimeUnit unit)

Implements io.netty5.util.concurrent.EventExecutor.schedule.

Doc from io.netty5.util.concurrent.EventExecutorGroup.schedule.

Schedule the given task for execution after the given delay, in the next available EventExecutor in this group, and return a future that produces a null result when the task completes.

Parameters
task:Runnable

The task that should be executed in this EventExecutorGroup after the given delay.

delay:long

A positive time delay, in the given time unit.

unit:TimeUnit

The non-null time unit for the delay.

Returns:Future<Void>

A future that represents the completion of the scheduled task.

Annotations
@Override
scheduleback to summary
public <V> Future<V> schedule(Callable<V> task, long delay, TimeUnit unit)

Implements io.netty5.util.concurrent.EventExecutor.schedule.

Doc from io.netty5.util.concurrent.EventExecutorGroup.schedule.

Schedule the given task for execution after the given delay, in the next available EventExecutor in this group, and return a future that will return the result of the callable when the task completes.

Parameters
<V>
The type of the future result.
task:Callable<V>

The task that should be executed in this EventExecutorGroup after the given delay.

delay:long

A positive time delay, in the given time unit.

unit:TimeUnit

The non-null time unit for the delay.

Returns:Future<V>

A future that represents the completion of the scheduled task.

Annotations
@Override
scheduleAtFixedRateback to summary
public Future<Void> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)

Implements io.netty5.util.concurrent.EventExecutor.scheduleAtFixedRate.

Doc from io.netty5.util.concurrent.EventExecutorGroup.scheduleAtFixedRate.

Schedule the given task for periodic execution in the next available EventExecutor. The first execution will occur after the given initial delay, and the following repeated executions will occur with the given period of time between each execution is started. If the task takes longer to complete than the requested period, then the following executions will be delayed, rather than allowing multiple instances of the task to run concurrently.

The task will be executed repeatedly until it either fails with an exception, or its future is cancelled. The future thus will never complete successfully.

Parameters
task:Runnable

The task that should be scheduled to execute at a fixed rate in this EventExecutorGroup.

initialDelay:long

The positive initial delay for the first task execution, in terms of the given time unit.

period:long

The positive period for the execution frequency to use after the first execution has started, in terms of the given time unit.

unit:TimeUnit

The non-null time unit for the delay and period.

Returns:Future<Void>

A future that represents the recurring task, and which can be cancelled to stop future executions.

Annotations
@Override
scheduleWithFixedDelayback to summary
public Future<Void> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)

Implements io.netty5.util.concurrent.EventExecutor.scheduleWithFixedDelay.

Doc from io.netty5.util.concurrent.EventExecutorGroup.scheduleWithFixedDelay.

Schedule the given task for periodic execution in the next available EventExecutor. The first execution will occur after the given initial delay, and the following repeated executions will occur with the given subsequent delay between one task completing and the next task starting. The delay from the completion of one task, to the start of the next, stays unchanged regardless of how long a task takes to complete.

This is in contrast to scheduleAtFixedRate(Runnable, long, long, TimeUnit) which varies the delays between the tasks in order to hit a given frequency.

The task will be executed repeatedly until it either fails with an exception, or its future is cancelled. The future thus will never complete successfully.

Parameters
task:Runnable

The task that should be scheduled to execute with fixed delays in this EventExecutorGroup.

initialDelay:long

The positive initial delay for the first task execution, in terms of the given time unit.

delay:long

The positive subsequent delay between task, to use after the first execution has completed, in terms of the given time unit.

unit:TimeUnit

The non-null time unit for the delays.

Returns:Future<Void>

A future that represents the recurring task, and which can be cancelled to stop future executions.

Annotations
@Override
shutdownGracefullyback to summary
public Future<Void> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit)

Implements io.netty5.util.concurrent.EventExecutorGroup.shutdownGracefully.

Doc from io.netty5.util.concurrent.EventExecutorGroup.shutdownGracefully.

Signals this executor that the caller wants the executor to be shut down. Once this method is called, isShuttingDown() starts to return true, and the executor prepares to shut itself down. This method ensures that no tasks are submitted for 'the quiet period' (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period, it is guaranteed to be accepted and the quiet period will start over.

Parameters
quietPeriod:long

the quiet period as described in the documentation

timeout:long

the maximum amount of time to wait until the executor is shutting down regardless if a task was submitted during the quiet period.

unit:TimeUnit

the unit of quietPeriod and timeout

Returns:Future<Void>

the terminationFuture()

Annotations
@Override
terminationFutureback to summary
public Future<Void> terminationFuture()

Implements io.netty5.util.concurrent.EventExecutorGroup.terminationFuture.

Doc from io.netty5.util.concurrent.EventExecutorGroup.terminationFuture.

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.

Returns:Future<Void>

The Future representing the termination of this EventExecutorGroup.

Annotations
@Override
io.netty5.util.concurrent back to summary

pack-priv Class ImmediateEventExecutor.ImmediatePromise<V>

extends DefaultPromise<V>
Class Inheritance

Field Summary

Inherited from io.netty5.util.concurrent.DefaultPromise:
NULL_CONTEXT

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
Inherited from io.netty5.util.concurrent.DefaultPromise:
acceptEitheracceptEitherAsyncacceptEitherAsyncaddListeneraddListenerapplyToEitherapplyToEitherAsyncapplyToEitherAsyncasFutureasStageawaitawaitcancelcancelcausecheckDeadLockexceptionallyexecutorfuturegetgetgetNowhandlehandleAsynchandleAsyncisCancellableisCancelledisDoneisFailedisSuccessnewFailedPromisenewSuccessfulPromisenotifyListener0runAfterBothrunAfterBothAsyncrunAfterBothAsyncrunAfterEitherrunAfterEitherAsyncrunAfterEitherAsyncsafeExecutesetFailuresetSuccesssetUncancellablesyncthenAcceptthenAcceptAsyncthenAcceptAsyncthenAcceptBoththenAcceptBothAsyncthenAcceptBothAsyncthenApplythenApplyAsyncthenApplyAsyncthenCombinethenCombineAsyncthenCombineAsyncthenComposethenComposeAsyncthenComposeAsyncthenRunthenRunAsyncthenRunAsynctoStringtoStringBuildertryFailuretrySuccesswhenCompletewhenCompleteAsyncwhenCompleteAsync

Constructor Detail

ImmediatePromiseback to summary
pack-priv ImmediatePromise(EventExecutor executor)

Method Detail

checkDeadLockback to summary
protected void checkDeadLock()

Overrides io.netty5.util.concurrent.DefaultPromise.checkDeadLock.

Annotations
@Override