Package io.netty.util.concurrent
Class AbstractEventExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- io.netty.util.concurrent.AbstractEventExecutor
-
- All Implemented Interfaces:
EventExecutor
,EventExecutorGroup
,java.lang.Iterable<EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
- Direct Known Subclasses:
AbstractEventLoop
,AbstractScheduledEventExecutor
,ImmediateEventExecutor
,NonStickyEventExecutorGroup.NonStickyOrderedEventExecutor
public abstract class AbstractEventExecutor extends java.util.concurrent.AbstractExecutorService implements EventExecutor
Abstract base class forEventExecutor
implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractEventExecutor.LazyRunnable
Marker interface forRunnable
to indicate that it should be queued for execution but does not need to run immediately.
-
Field Summary
Fields Modifier and Type Field Description (package private) static long
DEFAULT_SHUTDOWN_QUIET_PERIOD
(package private) static long
DEFAULT_SHUTDOWN_TIMEOUT
private static InternalLogger
logger
private EventExecutorGroup
parent
private java.util.Collection<EventExecutor>
selfCollection
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEventExecutor()
protected
AbstractEventExecutor(EventExecutorGroup parent)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
inEventLoop()
CallsEventExecutor.inEventLoop(Thread)
withThread.currentThread()
as argumentjava.util.Iterator<EventExecutor>
iterator()
void
lazyExecute(java.lang.Runnable task)
LikeExecutor.execute(Runnable)
but does not guarantee the task will be run until either a non-lazy task is executed or the executor is shut down.<V> Future<V>
newFailedFuture(java.lang.Throwable cause)
Create a newFuture
which 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 newFuture
which is marked as succeeded already.protected <T> java.util.concurrent.RunnableFuture<T>
newTaskFor(java.lang.Runnable runnable, T value)
protected <T> java.util.concurrent.RunnableFuture<T>
newTaskFor(java.util.concurrent.Callable<T> callable)
EventExecutor
next()
Returns a reference to itself.EventExecutorGroup
parent()
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,protected static void
safeExecute(java.lang.Runnable task)
Try to execute the givenRunnable
and just log if it throws aThrowable
.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)
abstract void
shutdown()
Deprecated.Future<?>
shutdownGracefully()
Shortcut method forEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
with sensible default values.java.util.List<java.lang.Runnable>
shutdownNow()
Deprecated.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)
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.EventExecutor
inEventLoop
-
Methods inherited from interface io.netty.util.concurrent.EventExecutorGroup
isShuttingDown, shutdownGracefully, terminationFuture
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
DEFAULT_SHUTDOWN_QUIET_PERIOD
static final long DEFAULT_SHUTDOWN_QUIET_PERIOD
- See Also:
- Constant Field Values
-
DEFAULT_SHUTDOWN_TIMEOUT
static final long DEFAULT_SHUTDOWN_TIMEOUT
- See Also:
- Constant Field Values
-
parent
private final EventExecutorGroup parent
-
selfCollection
private final java.util.Collection<EventExecutor> selfCollection
-
-
Constructor Detail
-
AbstractEventExecutor
protected AbstractEventExecutor()
-
AbstractEventExecutor
protected AbstractEventExecutor(EventExecutorGroup parent)
-
-
Method Detail
-
parent
public EventExecutorGroup parent()
Description copied from interface:EventExecutor
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,- Specified by:
parent
in interfaceEventExecutor
-
next
public EventExecutor next()
Description copied from interface:EventExecutor
Returns a reference to itself.- Specified by:
next
in interfaceEventExecutor
- Specified by:
next
in interfaceEventExecutorGroup
-
inEventLoop
public boolean inEventLoop()
Description copied from interface:EventExecutor
CallsEventExecutor.inEventLoop(Thread)
withThread.currentThread()
as argument- Specified by:
inEventLoop
in interfaceEventExecutor
-
iterator
public java.util.Iterator<EventExecutor> iterator()
- Specified by:
iterator
in interfaceEventExecutorGroup
- Specified by:
iterator
in interfacejava.lang.Iterable<EventExecutor>
-
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()
-
shutdown
@Deprecated public abstract void shutdown()
Deprecated.- Specified by:
shutdown
in interfaceEventExecutorGroup
- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
-
shutdownNow
@Deprecated public java.util.List<java.lang.Runnable> shutdownNow()
Deprecated.- Specified by:
shutdownNow
in interfaceEventExecutorGroup
- Specified by:
shutdownNow
in interfacejava.util.concurrent.ExecutorService
-
newPromise
public <V> Promise<V> newPromise()
Description copied from interface:EventExecutor
Return a newPromise
.- Specified by:
newPromise
in interfaceEventExecutor
-
newProgressivePromise
public <V> ProgressivePromise<V> newProgressivePromise()
Description copied from interface:EventExecutor
Create a newProgressivePromise
.- Specified by:
newProgressivePromise
in interfaceEventExecutor
-
newSucceededFuture
public <V> Future<V> newSucceededFuture(V result)
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
public <V> Future<V> newFailedFuture(java.lang.Throwable cause)
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
-
submit
public Future<?> submit(java.lang.Runnable task)
- Specified by:
submit
in interfaceEventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
- Overrides:
submit
in classjava.util.concurrent.AbstractExecutorService
-
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
- Overrides:
submit
in classjava.util.concurrent.AbstractExecutorService
-
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
- Overrides:
submit
in classjava.util.concurrent.AbstractExecutorService
-
newTaskFor
protected final <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable, T value)
- Overrides:
newTaskFor
in classjava.util.concurrent.AbstractExecutorService
-
newTaskFor
protected final <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)
- Overrides:
newTaskFor
in classjava.util.concurrent.AbstractExecutorService
-
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
-
safeExecute
protected static void safeExecute(java.lang.Runnable task)
Try to execute the givenRunnable
and just log if it throws aThrowable
.
-
lazyExecute
@UnstableApi public void lazyExecute(java.lang.Runnable task)
LikeExecutor.execute(Runnable)
but does not guarantee the task will be run until either a non-lazy task is executed or the executor is shut down. This is equivalent to submitting aEventExecutor.LazyRunnable
toExecutor.execute(Runnable)
but for an arbitraryRunnable
. The default implementation just delegates toExecutor.execute(Runnable)
.
-
-