Package io.netty.util.concurrent
Class UnorderedThreadPoolEventExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ScheduledThreadPoolExecutor
io.netty.util.concurrent.UnorderedThreadPoolEventExecutor
- All Implemented Interfaces:
EventExecutor
,EventExecutorGroup
,AutoCloseable
,Iterable<EventExecutor>
,Executor
,ExecutorService
,ScheduledExecutorService
public final class UnorderedThreadPoolEventExecutor
extends ScheduledThreadPoolExecutor
implements EventExecutor
EventExecutor
implementation which makes no guarantees about the ordering of task execution that
are submitted because there may be multiple threads executing these tasks.
This implementation is most useful for protocols that do not need strict ordering.
Because it provides no ordering care should be taken when using it!-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set
<EventExecutor> private static final InternalLogger
private final Promise
<?> -
Constructor Summary
ConstructorsConstructorDescriptionUnorderedThreadPoolEventExecutor
(int corePoolSize) UnorderedThreadPoolEventExecutor
(int corePoolSize, RejectedExecutionHandler handler) UnorderedThreadPoolEventExecutor
(int corePoolSize, ThreadFactory threadFactory) UnorderedThreadPoolEventExecutor
(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler) -
Method Summary
Modifier and TypeMethodDescriptionprotected <V> RunnableScheduledFuture
<V> decorateTask
(Runnable runnable, RunnableScheduledFuture<V> task) protected <V> RunnableScheduledFuture
<V> decorateTask
(Callable<V> callable, RunnableScheduledFuture<V> task) void
boolean
CallsEventExecutor.inEventLoop(Thread)
withThread.currentThread()
as argumentboolean
inEventLoop
(Thread thread) boolean
Returnstrue
if and only if allEventExecutor
s managed by thisEventExecutorGroup
are being shut down gracefully or was shut down.iterator()
<V> Future
<V> newFailedFuture
(Throwable cause) Create a newFuture
which is marked as failed already.<V> ProgressivePromise
<V> Create a newProgressivePromise
.<V> Promise
<V> Return a newPromise
.<V> Future
<V> newSucceededFuture
(V result) Create a newFuture
which is marked as succeeded already.next()
Returns a reference to itself.parent()
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,<V> ScheduledFuture
<V> scheduleAtFixedRate
(Runnable command, long initialDelay, long period, TimeUnit unit) scheduleWithFixedDelay
(Runnable command, long initialDelay, long delay, TimeUnit unit) void
shutdown()
Future
<?> Shortcut method forEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
with sensible default values.Future
<?> shutdownGracefully
(long quietPeriod, long timeout, TimeUnit unit) Signals this executor that the caller wants the executor to be shut down.Future
<?> <T> Future
<T> <T> Future
<T> Future
<?> Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor
getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toString
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, close, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
-
terminationFuture
-
executorSet
-
-
Constructor Details
-
UnorderedThreadPoolEventExecutor
public UnorderedThreadPoolEventExecutor(int corePoolSize) -
UnorderedThreadPoolEventExecutor
-
UnorderedThreadPoolEventExecutor
-
UnorderedThreadPoolEventExecutor
public UnorderedThreadPoolEventExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
-
Method Details
-
next
Description copied from interface:EventExecutor
Returns a reference to itself.- Specified by:
next
in interfaceEventExecutor
- Specified by:
next
in interfaceEventExecutorGroup
-
parent
Description copied from interface:EventExecutor
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,- Specified by:
parent
in interfaceEventExecutor
-
inEventLoop
public boolean inEventLoop()Description copied from interface:EventExecutor
CallsEventExecutor.inEventLoop(Thread)
withThread.currentThread()
as argument- Specified by:
inEventLoop
in interfaceEventExecutor
-
inEventLoop
Description copied from interface:EventExecutor
- Specified by:
inEventLoop
in interfaceEventExecutor
-
newPromise
Description copied from interface:EventExecutor
Return a newPromise
.- Specified by:
newPromise
in interfaceEventExecutor
-
newProgressivePromise
Description copied from interface:EventExecutor
Create a newProgressivePromise
.- Specified by:
newProgressivePromise
in interfaceEventExecutor
-
newSucceededFuture
Description copied from interface:EventExecutor
Create a newFuture
which is marked as succeeded already. SoFuture.isSuccess()
will returntrue
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuture
in interfaceEventExecutor
-
newFailedFuture
Description copied from interface:EventExecutor
Create a newFuture
which is marked as failed already. SoFuture.isSuccess()
will returnfalse
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuture
in interfaceEventExecutor
-
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
-
shutdownNow
- Specified by:
shutdownNow
in interfaceEventExecutorGroup
- Specified by:
shutdownNow
in interfaceExecutorService
- Overrides:
shutdownNow
in classScheduledThreadPoolExecutor
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceEventExecutorGroup
- Specified by:
shutdown
in interfaceExecutorService
- Overrides:
shutdown
in classScheduledThreadPoolExecutor
-
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
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
Description copied from interface:EventExecutorGroup
Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.- Specified by:
terminationFuture
in interfaceEventExecutorGroup
-
iterator
- Specified by:
iterator
in interfaceEventExecutorGroup
- Specified by:
iterator
in interfaceIterable<EventExecutor>
-
decorateTask
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) - Overrides:
decorateTask
in classScheduledThreadPoolExecutor
-
decorateTask
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task) - Overrides:
decorateTask
in classScheduledThreadPoolExecutor
-
schedule
- Specified by:
schedule
in interfaceEventExecutorGroup
- Specified by:
schedule
in interfaceScheduledExecutorService
- Overrides:
schedule
in classScheduledThreadPoolExecutor
-
schedule
- Specified by:
schedule
in interfaceEventExecutorGroup
- Specified by:
schedule
in interfaceScheduledExecutorService
- Overrides:
schedule
in classScheduledThreadPoolExecutor
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) - Specified by:
scheduleAtFixedRate
in interfaceEventExecutorGroup
- Specified by:
scheduleAtFixedRate
in interfaceScheduledExecutorService
- Overrides:
scheduleAtFixedRate
in classScheduledThreadPoolExecutor
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) - Specified by:
scheduleWithFixedDelay
in interfaceEventExecutorGroup
- Specified by:
scheduleWithFixedDelay
in interfaceScheduledExecutorService
- Overrides:
scheduleWithFixedDelay
in classScheduledThreadPoolExecutor
-
submit
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfaceExecutorService
- Overrides:
submit
in classScheduledThreadPoolExecutor
-
submit
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfaceExecutorService
- Overrides:
submit
in classScheduledThreadPoolExecutor
-
submit
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfaceExecutorService
- Overrides:
submit
in classScheduledThreadPoolExecutor
-
execute
- Specified by:
execute
in interfaceExecutor
- Overrides:
execute
in classScheduledThreadPoolExecutor
-