Package io.netty.util.concurrent
Class MultithreadEventExecutorGroup
java.lang.Object
io.netty.util.concurrent.AbstractEventExecutorGroup
io.netty.util.concurrent.MultithreadEventExecutorGroup
- All Implemented Interfaces:
EventExecutorGroup
,AutoCloseable
,Iterable<EventExecutor>
,Executor
,ExecutorService
,ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventExecutorGroup
,MultithreadEventLoopGroup
Abstract base class for
EventExecutorGroup
implementations that handles their tasks with multiple threads at
the same time.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EventExecutor[]
private final EventExecutorChooserFactory.EventExecutorChooser
private final Set
<EventExecutor> private final AtomicInteger
private final Promise
<?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
MultithreadEventExecutorGroup
(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, Object... args) Create a new instance.protected
MultithreadEventExecutorGroup
(int nThreads, Executor executor, Object... args) Create a new instance.protected
MultithreadEventExecutorGroup
(int nThreads, ThreadFactory threadFactory, Object... args) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long timeout, TimeUnit unit) final int
Return the number ofEventExecutor
this implementation uses.boolean
boolean
Returnstrue
if and only if allEventExecutor
s managed by thisEventExecutorGroup
are being shut down gracefully or was shut down.boolean
iterator()
protected abstract EventExecutor
Create a new EventExecutor which will later then accessible via thenext()
method.protected ThreadFactory
next()
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.void
shutdown()
Deprecated.Future
<?> shutdownGracefully
(long quietPeriod, long timeout, TimeUnit unit) Signals this executor that the caller wants the executor to be shut down.Future
<?> Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.Methods inherited from class io.netty.util.concurrent.AbstractEventExecutorGroup
execute, invokeAll, invokeAll, invokeAny, invokeAny, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.ExecutorService
close
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
children
-
readonlyChildren
-
terminatedChildren
-
terminationFuture
-
chooser
-
-
Constructor Details
-
MultithreadEventExecutorGroup
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.threadFactory
- the ThreadFactory to use, ornull
if the default should be used.args
- arguments which will passed to eachnewChild(Executor, Object...)
call
-
MultithreadEventExecutorGroup
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- the Executor to use, ornull
if the default should be used.args
- arguments which will passed to eachnewChild(Executor, Object...)
call
-
MultithreadEventExecutorGroup
protected MultithreadEventExecutorGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, Object... args) Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- the Executor to use, ornull
if the default should be used.chooserFactory
- theEventExecutorChooserFactory
to use.args
- arguments which will passed to eachnewChild(Executor, Object...)
call
-
-
Method Details
-
newDefaultThreadFactory
-
next
Description copied from interface:EventExecutorGroup
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
. -
iterator
-
executorCount
public final int executorCount()Return the number ofEventExecutor
this implementation uses. This number is the maps 1:1 to the threads it use. -
newChild
Create a new EventExecutor which will later then accessible via thenext()
method. This method will be called for each thread that will serve thisMultithreadEventExecutorGroup
.- Throws:
Exception
-
shutdownGracefully
Description copied from interface:EventExecutorGroup
Signals this executor that the caller wants the executor to be shut down. Once this method is called,EventExecutorGroup.isShuttingDown()
starts to returntrue
, and the executor prepares to shut itself down. UnlikeEventExecutorGroup.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
- the quiet period as described in the documentationtimeout
- the maximum amount of time to wait until the executor is EventExecutorGroup.shutdown() regardless if a task was submitted during the quiet periodunit
- the unit ofquietPeriod
andtimeout
- Returns:
- the
EventExecutorGroup.terminationFuture()
-
terminationFuture
Description copied from interface:EventExecutorGroup
Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated. -
shutdown
Deprecated.- Specified by:
shutdown
in interfaceEventExecutorGroup
- Specified by:
shutdown
in interfaceExecutorService
- Specified by:
shutdown
in classAbstractEventExecutorGroup
-
isShuttingDown
public boolean isShuttingDown()Description copied from interface:EventExecutorGroup
Returnstrue
if and only if allEventExecutor
s managed by thisEventExecutorGroup
are being shut down gracefully or was shut down. -
isShutdown
public boolean isShutdown() -
isTerminated
public boolean isTerminated() -
awaitTermination
- Throws:
InterruptedException
-