Package io.netty.util.concurrent
Class MultithreadEventExecutorGroup
- java.lang.Object
-
- io.netty.util.concurrent.AbstractEventExecutorGroup
-
- io.netty.util.concurrent.MultithreadEventExecutorGroup
-
- All Implemented Interfaces:
EventExecutorGroup
,java.lang.Iterable<EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventExecutorGroup
,MultithreadEventLoopGroup
public abstract class MultithreadEventExecutorGroup extends AbstractEventExecutorGroup
Abstract base class forEventExecutorGroup
implementations that handles their tasks with multiple threads at the same time.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MultithreadEventExecutorGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.lang.Object... args)
Create a new instance.protected
MultithreadEventExecutorGroup(int nThreads, java.util.concurrent.Executor executor, java.lang.Object... args)
Create a new instance.protected
MultithreadEventExecutorGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory, java.lang.Object... args)
Create a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
int
executorCount()
Return the number ofEventExecutor
this implementation uses.boolean
isShutdown()
boolean
isShuttingDown()
Returnstrue
if and only if allEventExecutor
s managed by thisEventExecutorGroup
are being shut down gracefully or was shut down.boolean
isTerminated()
java.util.Iterator<EventExecutor>
iterator()
protected abstract EventExecutor
newChild(java.util.concurrent.Executor executor, java.lang.Object... args)
Create a new EventExecutor which will later then accessible via thenext()
method.protected java.util.concurrent.ThreadFactory
newDefaultThreadFactory()
EventExecutor
next()
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.void
shutdown()
Deprecated.Future<?>
shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
Signals this executor that the caller wants the executor to be shut down.Future<?>
terminationFuture()
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
-
-
-
-
Constructor Detail
-
MultithreadEventExecutorGroup
protected MultithreadEventExecutorGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory, java.lang.Object... args)
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
protected MultithreadEventExecutorGroup(int nThreads, java.util.concurrent.Executor executor, java.lang.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.args
- arguments which will passed to eachnewChild(Executor, Object...)
call
-
MultithreadEventExecutorGroup
protected MultithreadEventExecutorGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.lang.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 Detail
-
newDefaultThreadFactory
protected java.util.concurrent.ThreadFactory newDefaultThreadFactory()
-
next
public EventExecutor next()
Description copied from interface:EventExecutorGroup
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.
-
iterator
public java.util.Iterator<EventExecutor> 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
protected abstract EventExecutor newChild(java.util.concurrent.Executor executor, java.lang.Object... args) throws java.lang.Exception
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:
java.lang.Exception
-
shutdownGracefully
public Future<?> shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
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
public Future<?> terminationFuture()
Description copied from interface:EventExecutorGroup
Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.
-
shutdown
@Deprecated public void shutdown()
Deprecated.- Specified by:
shutdown
in interfaceEventExecutorGroup
- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
- 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
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
-