Top Description Methods
io.netty.util.concurrent

public Interface EventExecutorGroup

extends ScheduledExecutorService, Iterable<EventExecutor>
Known Direct Subinterfaces
io.netty.util.concurrent.EventExecutor
Known Direct Implementers
io.netty.util.concurrent.NonStickyEventExecutorGroup, io.netty.util.concurrent.AbstractEventExecutorGroup
Imports
java.util.Iterator, .List, java.util.concurrent.Callable, .ScheduledExecutorService, .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 boolean
isShuttingDown()

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

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 ScheduledFuture<?>
schedule(Runnable
the task to execute
command
,
long
the time from now to delay execution
delay
,
TimeUnit
the time unit of the delay parameter
unit
)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Submits a one-shot task that becomes enabled after the given delay.
public <V> ScheduledFuture<V>
schedule(Callable<V>
the function to execute
callable
,
long
the time from now to delay execution
delay
,
TimeUnit
the time unit of the delay parameter
unit
)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.
public ScheduledFuture<?>
scheduleAtFixedRate(Runnable
the task to execute
command
,
long
the time to delay first execution
initialDelay
,
long
the period between successive executions
period
,
TimeUnit
the time unit of the initialDelay and period parameters
unit
)

Redeclares java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after initialDelay, then initialDelay + period, then initialDelay + 2 * period, and so on.
public ScheduledFuture<?>
scheduleWithFixedDelay(Runnable
the task to execute
command
,
long
the time to delay first execution
initialDelay
,
long
the delay between the termination of one execution and the commencement of the next
delay
,
TimeUnit
the time unit of the initialDelay and delay parameters
unit
)

Redeclares java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.
public void
shutdown()

Redeclares java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
public Future<?>

Returns:

the terminationFuture()
shutdownGracefully
()

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

public Future<?>

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 shutdown() 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 List<Runnable>
shutdownNow()

Redeclares java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
public Future<?>
submit(Runnable
the task to submit
task
)

Redeclares java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public <T> Future<T>
submit(Runnable
the task to submit
task
,
T
the result to return
result
)

Redeclares java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public <T> Future<T>
submit(Callable<T>
the task to submit
task
)

Redeclares java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task.
public Future<?>
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

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.

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 ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Doc from java.util.concurrent.ScheduledExecutorService.schedule.

Submits a one-shot task that becomes enabled after the given delay.

Parameters
command:Runnable

the task to execute

delay:long

the time from now to delay execution

unit:TimeUnit

the time unit of the delay parameter

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion

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

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Doc from java.util.concurrent.ScheduledExecutorService.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.

Parameters
<V>
the type of the callable's result
callable:Callable<V>

the function to execute

delay:long

the time from now to delay execution

unit:TimeUnit

the time unit of the delay parameter

Returns:ScheduledFuture<V>

a ScheduledFuture that can be used to extract result or cancel

Annotations
@Override
scheduleAtFixedRateback to summary
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate.

Doc from java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after initialDelay, then initialDelay + period, then initialDelay + 2 * period, and so on.

The sequence of task executions continues indefinitely until one of the following exceptional completions occur:

  • The task is explicitly cancelled via the returned future.
  • The executor terminates, also resulting in task cancellation.
  • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.

If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

Parameters
command:Runnable

the task to execute

initialDelay:long

the time to delay first execution

period:long

the period between successive executions

unit:TimeUnit

the time unit of the initialDelay and period parameters

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.

Annotations
@Override
scheduleWithFixedDelayback to summary
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay.

Doc from java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.

The sequence of task executions continues indefinitely until one of the following exceptional completions occur:

  • The task is explicitly cancelled via the returned future.
  • The executor terminates, also resulting in task cancellation.
  • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.
Parameters
command:Runnable

the task to execute

initialDelay:long

the time to delay first execution

delay:long

the delay between the termination of one execution and the commencement of the next

unit:TimeUnit

the time unit of the initialDelay and delay parameters

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.

Annotations
@Override
shutdownback to summary
public void shutdown()

Redeclares java.util.concurrent.ExecutorService.shutdown.

Doc from java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.

This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

Annotations
@Override
@Deprecated
shutdownGracefullyback to summary
public Future<?> shutdownGracefully()

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

Returns:Future<?>

the terminationFuture()

shutdownGracefullyback to summary
public Future<?> 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. Unlike shutdown(), graceful shutdown 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 shutdown() regardless if a task was submitted during the quiet period

unit:TimeUnit

the unit of quietPeriod and timeout

Returns:Future<?>

the terminationFuture()

shutdownNowback to summary
public List<Runnable> shutdownNow()

Redeclares java.util.concurrent.ExecutorService.shutdownNow.

Doc from java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that.

There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. For example, typical implementations will cancel via Thread#interrupt, so any task that fails to respond to interrupts may never terminate.

Returns:List<Runnable>

list of tasks that never commenced execution

Annotations
@Override
@Deprecated
submitback to summary
public Future<?> submit(Runnable task)

Redeclares java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.

Parameters
task:Runnable

the task to submit

Returns:Future<?>

a Future representing pending completion of the task

Annotations
@Override
submitback to summary
public <T> Future<T> submit(Runnable task, T result)

Redeclares java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.

Parameters
<T>
the type of the result
task:Runnable

the task to submit

result:T

the result to return

Returns:Future<T>

a Future representing pending completion of the task

Annotations
@Override
submitback to summary
public <T> Future<T> submit(Callable<T> task)

Redeclares java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

Note

The Executors class includes a set of methods that can convert some other common closure-like objects, for example, java.security.PrivilegedAction to Callable form so they can be submitted.

Parameters
<T>
the type of the task's result
task:Callable<T>

the task to submit

Returns:Future<T>

a Future representing pending completion of the task

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

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