Top Description Fields Constructors Methods
io.netty.util.concurrent

public abstract Class MultithreadEventExecutorGroup

extends AbstractEventExecutorGroup
Class Inheritance
Known Direct Subclasses
io.netty.util.concurrent.DefaultEventExecutorGroup
Static Imports
io.netty.util.internal.ObjectUtil.checkPositive

Abstract base class for EventExecutorGroup implementations that handles their tasks with multiple threads at the same time.

Field Summary

Modifier and TypeField and Description
private final EventExecutor[]
private final EventExecutorChooserFactory.EventExecutorChooser
private final Set<EventExecutor>
private final AtomicInteger
private final Promise<?>

Constructor Summary

AccessConstructor and Description
protected
MultithreadEventExecutorGroup(int
the number of threads that will be used by this instance.
nThreads
,
ThreadFactory
the ThreadFactory to use, or null if the default should be used.
threadFactory
,
Object...
arguments which will passed to each newChild(Executor, Object...) call
args
)

Create a new instance.

protected
MultithreadEventExecutorGroup(int
the number of threads that will be used by this instance.
nThreads
,
Executor
the Executor to use, or null if the default should be used.
executor
,
Object...
arguments which will passed to each newChild(Executor, Object...) call
args
)

Create a new instance.

protected
MultithreadEventExecutorGroup(int
the number of threads that will be used by this instance.
nThreads
,
Executor
the Executor to use, or null if the default should be used.
executor
,
EventExecutorChooserFactory chooserFactory, Object...
arguments which will passed to each newChild(Executor, Object...) call
args
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
awaitTermination(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
public final int
executorCount()

Return the number of EventExecutor this implementation uses.

public boolean
isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.
public boolean
public boolean
isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down.
public Iterator<EventExecutor>
iterator()

Implements io.netty.util.concurrent.EventExecutorGroup.iterator.

Returns an iterator over elements of type T.
protected abstract EventExecutor
newChild(Executor executor, Object... args)

Create a new EventExecutor which will later then accessible via the next() method.

protected ThreadFactory
public EventExecutor
public void
shutdown()

Implements abstract io.netty.util.concurrent.AbstractEventExecutorGroup.shutdown.

Implements io.netty.util.concurrent.EventExecutorGroup.shutdown.

Deprecated
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
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 shutdown() regardless if a task was submitted during the quiet period
timeout
,
TimeUnit
the unit of quietPeriod and timeout
unit
)

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

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

Implements io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.
Inherited from io.netty.util.concurrent.AbstractEventExecutorGroup:
executeinvokeAllinvokeAllinvokeAnyinvokeAnyscheduleschedulescheduleAtFixedRatescheduleWithFixedDelayshutdownGracefullyshutdownNowsubmitsubmitsubmit

Field Detail

childrenback to summary
private final EventExecutor[] children
chooserback to summary
private final EventExecutorChooserFactory.EventExecutorChooser chooser
readonlyChildrenback to summary
private final Set<EventExecutor> readonlyChildren
terminatedChildrenback to summary
private final AtomicInteger terminatedChildren
terminationFutureback to summary
private final Promise<?> terminationFuture

Constructor Detail

MultithreadEventExecutorGroupback to summary
protected MultithreadEventExecutorGroup(int nThreads, ThreadFactory threadFactory, Object... args)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

threadFactory:ThreadFactory

the ThreadFactory to use, or null if the default should be used.

args:Object[]

arguments which will passed to each newChild(Executor, Object...) call

MultithreadEventExecutorGroupback to summary
protected MultithreadEventExecutorGroup(int nThreads, Executor executor, Object... args)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

executor:Executor

the Executor to use, or null if the default should be used.

args:Object[]

arguments which will passed to each newChild(Executor, Object...) call

MultithreadEventExecutorGroupback to summary
protected MultithreadEventExecutorGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, Object... args)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

executor:Executor

the Executor to use, or null if the default should be used.

chooserFactory:EventExecutorChooserFactory

the EventExecutorChooserFactory to use.

args:Object[]

arguments which will passed to each newChild(Executor, Object...) call

Method Detail

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

Implements java.util.concurrent.ExecutorService.awaitTermination.

Doc from java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:boolean

true if this executor terminated and false if the timeout elapsed before termination

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
executorCountback to summary
public final int executorCount()

Return the number of EventExecutor this implementation uses. This number is the maps 1:1 to the threads it use.

isShutdownback to summary
public boolean isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Doc from java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.

Returns:boolean

true if this executor has been shut down

Annotations
@Override
isShuttingDownback to summary
public boolean isShuttingDown()

Implements io.netty.util.concurrent.EventExecutorGroup.isShuttingDown.

Doc from io.netty.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.

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Doc from java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down. Note that isTerminated is never true unless either shutdown or shutdownNow was called first.

Returns:boolean

true if all tasks have completed following shut down

Annotations
@Override
iteratorback to summary
public Iterator<EventExecutor> iterator()

Implements io.netty.util.concurrent.EventExecutorGroup.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<EventExecutor>

an Iterator.

Annotations
@Override
newChildback to summary
protected abstract EventExecutor newChild(Executor executor, Object... args) throws Exception

Create a new EventExecutor which will later then accessible via the next() method. This method will be called for each thread that will serve this MultithreadEventExecutorGroup.

newDefaultThreadFactoryback to summary
protected ThreadFactory newDefaultThreadFactory()
nextback to summary
public EventExecutor next()

Implements io.netty.util.concurrent.EventExecutorGroup.next.

Doc from io.netty.util.concurrent.EventExecutorGroup.next.

Returns one of the EventExecutors managed by this EventExecutorGroup.

Annotations
@Override
shutdownback to summary
public void shutdown()

Implements abstract io.netty.util.concurrent.AbstractEventExecutorGroup.shutdown.

Implements io.netty.util.concurrent.EventExecutorGroup.shutdown.

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

Deprecated

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(long quietPeriod, long timeout, TimeUnit unit)

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

Doc from io.netty.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. 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()

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

Implements io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

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

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

Annotations
@Override