Package io.netty.util.concurrent
Class NonStickyEventExecutorGroup
- java.lang.Object
-
- io.netty.util.concurrent.NonStickyEventExecutorGroup
-
- All Implemented Interfaces:
EventExecutorGroup
,java.lang.Iterable<EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
@UnstableApi public final class NonStickyEventExecutorGroup extends java.lang.Object implements EventExecutorGroup
EventExecutorGroup
which will preserveRunnable
execution order but makes no guarantees about whatEventExecutor
(and thereforeThread
) will be used to execute theRunnable
s.The
EventExecutorGroup.next()
for the wrappedEventExecutorGroup
must NOT return executors of typeOrderedEventExecutor
.
-
-
Constructor Summary
Constructors Constructor Description NonStickyEventExecutorGroup(EventExecutorGroup group)
Creates a new instance.NonStickyEventExecutorGroup(EventExecutorGroup group, int maxTaskExecutePerRun)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
void
execute(java.lang.Runnable command)
<T> java.util.List<java.util.concurrent.Future<T>>
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
<T> java.util.List<java.util.concurrent.Future<T>>
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
<T> T
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
<T> T
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
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()
EventExecutor
next()
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.ScheduledFuture<?>
schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
<V> ScheduledFuture<V>
schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
ScheduledFuture<?>
scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
ScheduledFuture<?>
scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
void
shutdown()
Future<?>
shutdownGracefully()
Shortcut method forEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
with sensible default values.Future<?>
shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
Signals this executor that the caller wants the executor to be shut down.java.util.List<java.lang.Runnable>
shutdownNow()
Future<?>
submit(java.lang.Runnable task)
<T> Future<T>
submit(java.lang.Runnable task, T result)
<T> Future<T>
submit(java.util.concurrent.Callable<T> task)
Future<?>
terminationFuture()
Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.
-
-
-
Constructor Detail
-
NonStickyEventExecutorGroup
public NonStickyEventExecutorGroup(EventExecutorGroup group)
Creates a new instance. Be aware that the givenEventExecutorGroup
MUST NOT contain anyOrderedEventExecutor
s.
-
NonStickyEventExecutorGroup
public NonStickyEventExecutorGroup(EventExecutorGroup group, int maxTaskExecutePerRun)
Creates a new instance. Be aware that the givenEventExecutorGroup
MUST NOT contain anyOrderedEventExecutor
s.
-
-
Method Detail
-
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.- Specified by:
isShuttingDown
in interfaceEventExecutorGroup
-
shutdownGracefully
public Future<?> shutdownGracefully()
Description copied from interface:EventExecutorGroup
Shortcut method forEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
with sensible default values.- Specified by:
shutdownGracefully
in interfaceEventExecutorGroup
- Returns:
- the
EventExecutorGroup.terminationFuture()
-
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.- Specified by:
shutdownGracefully
in interfaceEventExecutorGroup
- 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.- Specified by:
terminationFuture
in interfaceEventExecutorGroup
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceEventExecutorGroup
- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNow
in interfaceEventExecutorGroup
- Specified by:
shutdownNow
in interfacejava.util.concurrent.ExecutorService
-
next
public EventExecutor next()
Description copied from interface:EventExecutorGroup
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.- Specified by:
next
in interfaceEventExecutorGroup
-
iterator
public java.util.Iterator<EventExecutor> iterator()
- Specified by:
iterator
in interfaceEventExecutorGroup
- Specified by:
iterator
in interfacejava.lang.Iterable<EventExecutor>
-
submit
public Future<?> submit(java.lang.Runnable task)
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> Future<T> submit(java.lang.Runnable task, T result)
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> Future<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
schedule
public ScheduledFuture<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedule
in interfaceEventExecutorGroup
- Specified by:
schedule
in interfacejava.util.concurrent.ScheduledExecutorService
-
schedule
public <V> ScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedule
in interfaceEventExecutorGroup
- Specified by:
schedule
in interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleAtFixedRate
in interfaceEventExecutorGroup
- Specified by:
scheduleAtFixedRate
in interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleWithFixedDelay
in interfaceEventExecutorGroup
- Specified by:
scheduleWithFixedDelay
in interfacejava.util.concurrent.ScheduledExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
awaitTermination
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
-