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,Iterable<EventExecutor>,Executor,ExecutorService,ScheduledExecutorService
public final class UnorderedThreadPoolEventExecutor extends ScheduledThreadPoolExecutor implements EventExecutor
EventExecutorimplementation 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 classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Constructor Summary
Constructors Constructor Description UnorderedThreadPoolEventExecutor(int corePoolSize)UnorderedThreadPoolEventExecutor(int corePoolSize, RejectedExecutionHandler handler)UnorderedThreadPoolEventExecutor(int corePoolSize, ThreadFactory threadFactory)UnorderedThreadPoolEventExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <V> RunnableScheduledFuture<V>decorateTask(Runnable runnable, RunnableScheduledFuture<V> task)protected <V> RunnableScheduledFuture<V>decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task)voidexecute(Runnable command)booleaninEventLoop()CallsEventExecutor.inEventLoop(Thread)withThread.currentThread()as argumentbooleaninEventLoop(Thread thread)booleanisShuttingDown()Returnstrueif and only if allEventExecutors managed by thisEventExecutorGroupare being shut down gracefully or was shut down.Iterator<EventExecutor>iterator()<V> Future<V>newFailedFuture(Throwable cause)Create a newFuturewhich is marked as failed already.<V> ProgressivePromise<V>newProgressivePromise()Create a newProgressivePromise.<V> Promise<V>newPromise()Return a newPromise.<V> Future<V>newSucceededFuture(V result)Create a newFuturewhich is marked as succeeded already.EventExecutornext()Returns one of theEventExecutors managed by thisEventExecutorGroup.EventExecutorGroupparent()Return theEventExecutorGroupwhich is the parent of thisEventExecutor,ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit)<V> ScheduledFuture<V>schedule(Callable<V> callable, long delay, TimeUnit unit)ScheduledFuture<?>scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)voidshutdown()Future<?>shutdownGracefully()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.List<Runnable>shutdownNow()Future<?>submit(Runnable task)<T> Future<T>submit(Runnable task, T result)<T> Future<T>submit(Callable<T> task)Future<?>terminationFuture()Returns theFuturewhich is notified when allEventExecutors managed by thisEventExecutorGrouphave 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, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
UnorderedThreadPoolEventExecutor
public UnorderedThreadPoolEventExecutor(int corePoolSize)
-
UnorderedThreadPoolEventExecutor
public UnorderedThreadPoolEventExecutor(int corePoolSize, ThreadFactory threadFactory)
-
UnorderedThreadPoolEventExecutor
public UnorderedThreadPoolEventExecutor(int corePoolSize, RejectedExecutionHandler handler)
-
UnorderedThreadPoolEventExecutor
public UnorderedThreadPoolEventExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
-
Method Detail
-
next
public EventExecutor next()
Description copied from interface:EventExecutorGroupReturns one of theEventExecutors managed by thisEventExecutorGroup.- Specified by:
nextin interfaceEventExecutorGroup
-
parent
public EventExecutorGroup parent()
Description copied from interface:EventExecutorReturn theEventExecutorGroupwhich is the parent of thisEventExecutor,- Specified by:
parentin interfaceEventExecutor
-
inEventLoop
public boolean inEventLoop()
Description copied from interface:EventExecutorCallsEventExecutor.inEventLoop(Thread)withThread.currentThread()as argument- Specified by:
inEventLoopin interfaceEventExecutor
-
inEventLoop
public boolean inEventLoop(Thread thread)
Description copied from interface:EventExecutor- Specified by:
inEventLoopin interfaceEventExecutor
-
newPromise
public <V> Promise<V> newPromise()
Description copied from interface:EventExecutorReturn a newPromise.- Specified by:
newPromisein interfaceEventExecutor
-
newProgressivePromise
public <V> ProgressivePromise<V> newProgressivePromise()
Description copied from interface:EventExecutorCreate a newProgressivePromise.- Specified by:
newProgressivePromisein interfaceEventExecutor
-
newSucceededFuture
public <V> Future<V> newSucceededFuture(V result)
Description copied from interface:EventExecutorCreate a newFuturewhich is marked as succeeded already. SoFuture.isSuccess()will returntrue. AllFutureListeneradded to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuturein interfaceEventExecutor
-
newFailedFuture
public <V> Future<V> newFailedFuture(Throwable cause)
Description copied from interface:EventExecutorCreate a newFuturewhich is marked as failed already. SoFuture.isSuccess()will returnfalse. AllFutureListeneradded to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuturein interfaceEventExecutor
-
isShuttingDown
public boolean isShuttingDown()
Description copied from interface:EventExecutorGroupReturnstrueif and only if allEventExecutors managed by thisEventExecutorGroupare being shut down gracefully or was shut down.- Specified by:
isShuttingDownin interfaceEventExecutorGroup
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNowin interfaceEventExecutorGroup- Specified by:
shutdownNowin interfaceExecutorService- Overrides:
shutdownNowin classScheduledThreadPoolExecutor
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceEventExecutorGroup- Specified by:
shutdownin interfaceExecutorService- Overrides:
shutdownin classScheduledThreadPoolExecutor
-
shutdownGracefully
public Future<?> shutdownGracefully()
Description copied from interface:EventExecutorGroupShortcut method forEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)with sensible default values.- Specified by:
shutdownGracefullyin interfaceEventExecutorGroup- Returns:
- the
EventExecutorGroup.terminationFuture()
-
shutdownGracefully
public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit)
Description copied from interface:EventExecutorGroupSignals 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:
shutdownGracefullyin 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 ofquietPeriodandtimeout- Returns:
- the
EventExecutorGroup.terminationFuture()
-
terminationFuture
public Future<?> terminationFuture()
Description copied from interface:EventExecutorGroupReturns theFuturewhich is notified when allEventExecutors managed by thisEventExecutorGrouphave been terminated.- Specified by:
terminationFuturein interfaceEventExecutorGroup
-
iterator
public Iterator<EventExecutor> iterator()
- Specified by:
iteratorin interfaceEventExecutorGroup- Specified by:
iteratorin interfaceIterable<EventExecutor>
-
decorateTask
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task)
- Overrides:
decorateTaskin classScheduledThreadPoolExecutor
-
decorateTask
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task)
- Overrides:
decorateTaskin classScheduledThreadPoolExecutor
-
schedule
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
- Specified by:
schedulein interfaceEventExecutorGroup- Specified by:
schedulein interfaceScheduledExecutorService- Overrides:
schedulein classScheduledThreadPoolExecutor
-
schedule
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
- Specified by:
schedulein interfaceEventExecutorGroup- Specified by:
schedulein interfaceScheduledExecutorService- Overrides:
schedulein classScheduledThreadPoolExecutor
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
- Specified by:
scheduleAtFixedRatein interfaceEventExecutorGroup- Specified by:
scheduleAtFixedRatein interfaceScheduledExecutorService- Overrides:
scheduleAtFixedRatein classScheduledThreadPoolExecutor
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
- Specified by:
scheduleWithFixedDelayin interfaceEventExecutorGroup- Specified by:
scheduleWithFixedDelayin interfaceScheduledExecutorService- Overrides:
scheduleWithFixedDelayin classScheduledThreadPoolExecutor
-
submit
public Future<?> submit(Runnable task)
- Specified by:
submitin interfaceEventExecutorGroup- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classScheduledThreadPoolExecutor
-
submit
public <T> Future<T> submit(Runnable task, T result)
- Specified by:
submitin interfaceEventExecutorGroup- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classScheduledThreadPoolExecutor
-
submit
public <T> Future<T> submit(Callable<T> task)
- Specified by:
submitin interfaceEventExecutorGroup- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classScheduledThreadPoolExecutor
-
execute
public void execute(Runnable command)
- Specified by:
executein interfaceExecutor- Overrides:
executein classScheduledThreadPoolExecutor
-
-