@UnstableApi public final class NonStickyEventExecutorGroup extends java.lang.Object implements EventExecutorGroup
EventExecutorGroup
which will preserve Runnable
execution order but makes no guarantees about what
EventExecutor
(and therefore Thread
) will be used to execute the Runnable
s.
The EventExecutorGroup.next()
for the wrapped EventExecutorGroup
must NOT return
executors of type OrderedEventExecutor
.
Modifier and Type | Class and Description |
---|---|
private static class |
NonStickyEventExecutorGroup.NonStickyOrderedEventExecutor |
Modifier and Type | Field and Description |
---|---|
private EventExecutorGroup |
group |
private int |
maxTaskExecutePerRun |
Constructor and Description |
---|
NonStickyEventExecutorGroup(EventExecutorGroup group)
Creates a new instance.
|
NonStickyEventExecutorGroup(EventExecutorGroup group,
int maxTaskExecutePerRun)
Creates a new instance.
|
Modifier and Type | Method and 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()
Returns
true if and only if all EventExecutor s managed by this EventExecutorGroup
are being shut down gracefully or was shut down. |
boolean |
isTerminated() |
java.util.Iterator<EventExecutor> |
iterator() |
private NonStickyEventExecutorGroup.NonStickyOrderedEventExecutor |
newExecutor(EventExecutor executor) |
EventExecutor |
next()
Returns one of the
EventExecutor s managed by this EventExecutorGroup . |
<V> ScheduledFuture<V> |
schedule(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit) |
ScheduledFuture<?> |
schedule(java.lang.Runnable command,
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 for
EventExecutorGroup.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() |
<T> Future<T> |
submit(java.util.concurrent.Callable<T> task) |
Future<?> |
submit(java.lang.Runnable task) |
<T> Future<T> |
submit(java.lang.Runnable task,
T result) |
Future<?> |
terminationFuture()
Returns the
Future which is notified when all EventExecutor s managed by this
EventExecutorGroup have been terminated. |
private static EventExecutorGroup |
verify(EventExecutorGroup group) |
private final EventExecutorGroup group
private final int maxTaskExecutePerRun
public NonStickyEventExecutorGroup(EventExecutorGroup group)
EventExecutorGroup
MUST NOT contain
any OrderedEventExecutor
s.public NonStickyEventExecutorGroup(EventExecutorGroup group, int maxTaskExecutePerRun)
EventExecutorGroup
MUST NOT contain
any OrderedEventExecutor
s.private static EventExecutorGroup verify(EventExecutorGroup group)
private NonStickyEventExecutorGroup.NonStickyOrderedEventExecutor newExecutor(EventExecutor executor)
public boolean isShuttingDown()
EventExecutorGroup
true
if and only if all EventExecutor
s managed by this EventExecutorGroup
are being shut down gracefully or was shut down.isShuttingDown
in interface EventExecutorGroup
public Future<?> shutdownGracefully()
EventExecutorGroup
EventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
with sensible default values.shutdownGracefully
in interface EventExecutorGroup
EventExecutorGroup.terminationFuture()
public Future<?> shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
EventExecutorGroup
EventExecutorGroup.isShuttingDown()
starts to return true
, and the executor prepares to shut itself down.
Unlike EventExecutorGroup.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.shutdownGracefully
in interface EventExecutorGroup
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 of quietPeriod
and timeout
EventExecutorGroup.terminationFuture()
public Future<?> terminationFuture()
EventExecutorGroup
Future
which is notified when all EventExecutor
s managed by this
EventExecutorGroup
have been terminated.terminationFuture
in interface EventExecutorGroup
public void shutdown()
shutdown
in interface EventExecutorGroup
shutdown
in interface java.util.concurrent.ExecutorService
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow
in interface EventExecutorGroup
shutdownNow
in interface java.util.concurrent.ExecutorService
public EventExecutor next()
EventExecutorGroup
EventExecutor
s managed by this EventExecutorGroup
.next
in interface EventExecutorGroup
public java.util.Iterator<EventExecutor> iterator()
iterator
in interface EventExecutorGroup
iterator
in interface java.lang.Iterable<EventExecutor>
public Future<?> submit(java.lang.Runnable task)
submit
in interface EventExecutorGroup
submit
in interface java.util.concurrent.ExecutorService
public <T> Future<T> submit(java.lang.Runnable task, T result)
submit
in interface EventExecutorGroup
submit
in interface java.util.concurrent.ExecutorService
public <T> Future<T> submit(java.util.concurrent.Callable<T> task)
submit
in interface EventExecutorGroup
submit
in interface java.util.concurrent.ExecutorService
public ScheduledFuture<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
schedule
in interface EventExecutorGroup
schedule
in interface java.util.concurrent.ScheduledExecutorService
public <V> ScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
schedule
in interface EventExecutorGroup
schedule
in interface java.util.concurrent.ScheduledExecutorService
public ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
scheduleAtFixedRate
in interface EventExecutorGroup
scheduleAtFixedRate
in interface java.util.concurrent.ScheduledExecutorService
public ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
scheduleWithFixedDelay
in interface EventExecutorGroup
scheduleWithFixedDelay
in interface java.util.concurrent.ScheduledExecutorService
public boolean isShutdown()
isShutdown
in interface java.util.concurrent.ExecutorService
public boolean isTerminated()
isTerminated
in interface java.util.concurrent.ExecutorService
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
awaitTermination
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
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
invokeAll
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
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
invokeAll
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
invokeAny
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
java.util.concurrent.ExecutionException
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
invokeAny
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public void execute(java.lang.Runnable command)
execute
in interface java.util.concurrent.Executor