Top Description Methods
io.netty5.util.concurrent

public Interface EventExecutorGroup

extends Iterable<EventExecutor>, Executor
Known Direct Subinterfaces
io.netty5.util.concurrent.EventExecutor
Known Direct Implementers
io.netty5.util.concurrent.MultithreadEventExecutorGroup, io.netty5.util.concurrent.NonStickyEventExecutorGroup
Imports
java.util.Iterator, java.util.concurrent.Callable, .Executor, .TimeUnit

The EventExecutorGroup is responsible for providing the EventExecutor's to use via its next() method. Besides this, it is also responsible for handling their life-cycle and allows shutting them down in a global fashion.

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

true if the executor group terminated within the specific timeout.
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
)

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

public default void
execute(Runnable
the runnable task
task
)

Implements java.util.concurrent.Executor.execute.

Executes the given command at some time in the future.
public boolean

Returns:

true if all executors in this group have shut down and are no longer accepting any new tasks.
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

Returns:

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

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

public default boolean

Returns:

true if all executors in this group have terminated.
isTerminated
()

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

public Iterator<EventExecutor>
iterator()

Redeclares java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public EventExecutor
next()

Returns one of the EventExecutors managed by this EventExecutorGroup.

public default Future<Void>

Returns:

A future that represents the completion of the scheduled task.
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
)

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 default <
The type of the future result.
V
>
Future<V>

Returns:

A future that represents the completion of the scheduled task.
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
)

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 default Future<Void>

Returns:

A future that represents the recurring task, and which can be cancelled to stop future executions.
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
)

Schedule the given task for periodic execution in the next available EventExecutor.

public default Future<Void>

Returns:

A future that represents the recurring task, and which can be cancelled to stop future executions.
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
)

Schedule the given task for periodic execution in the next available EventExecutor.

public default Future<Void>

Returns:

the terminationFuture()
shutdownGracefully
()

Shortcut method for shutdownGracefully(long, long, TimeUnit) with sensible default values.

public Future<Void>

Returns:

the terminationFuture()
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
)

Signals this executor that the caller wants the executor to be shut down.

public default Future<Void>

Returns:

A future that represents the completion of the submitted task.
submit
(Runnable
The task that should be executed in this EventExecutorGroup.
task
)

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

public default <
The type of the future result.
T
>
Future<T>

Returns:

A future that represents the completion of the submitted task.
submit
(Runnable
The task that should be executed in this EventExecutorGroup.
task
,
T
The value that the returned future will complete with, if the task completes successfully.
result
)

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

public default <
The type of the future result.
T
>
Future<T>

Returns:

A future that represents the completion of the submitted task.
submit
(Callable<T>
The task that should be executed in this EventExecutorGroup.
task
)

Submit the given task for execution 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>

Returns:

The Future representing the termination of this EventExecutorGroup.
terminationFuture
()

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

Inherited from java.lang.Iterable:
forEachspliterator

Method Detail

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

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.

Exceptions
InterruptedException:
If this thread was interrupted while waiting for executor group to terminate.
executeback to summary
public default void execute(Runnable task)

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
task:Runnable

the runnable task

Annotations
@Override
isShutdownback to summary
public boolean 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.

isShuttingDownback to summary
public boolean 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.

isTerminatedback to summary
public default boolean 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.

iteratorback to summary
public Iterator<EventExecutor> iterator()

Redeclares java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<EventExecutor>

an Iterator.

Annotations
@Override
nextback to summary
public EventExecutor next()

Returns one of the EventExecutors managed by this EventExecutorGroup.

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

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.

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

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.

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

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.

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

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.

shutdownGracefullyback to summary
public default Future<Void> shutdownGracefully()

Shortcut method for shutdownGracefully(long, long, TimeUnit) with sensible default values.

Returns:Future<Void>

the terminationFuture()

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

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()

submitback to summary
public default Future<Void> submit(Runnable task)

Submit the given task for execution 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.

Returns:Future<Void>

A future that represents the completion of the submitted task.

submitback to summary
public default <T> Future<T> submit(Runnable task, T result)

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

Parameters
<T>
The type of the future result.
task:Runnable

The task that should be executed in this EventExecutorGroup.

result:T

The value that the returned future will complete with, if the task completes successfully.

Returns:Future<T>

A future that represents the completion of the submitted task.

submitback to summary
public default <T> Future<T> submit(Callable<T> task)

Submit the given task for execution 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
<T>
The type of the future result.
task:Callable<T>

The task that should be executed in this EventExecutorGroup.

Returns:Future<T>

A future that represents the completion of the submitted task.

terminationFutureback to summary
public Future<Void> 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.