-
- All Superinterfaces:
EventExecutorGroup
,Executor
,FuturePromiseFactory
,Iterable<EventExecutor>
- All Known Subinterfaces:
EventLoop
,OrderedEventExecutor
- All Known Implementing Classes:
AbstractEventExecutor
,AbstractScheduledEventExecutor
,GlobalEventExecutor
,ImmediateEventExecutor
,SingleThreadEventExecutor
,SingleThreadEventLoop
,UnorderedThreadPoolEventExecutor
public interface EventExecutor extends EventExecutorGroup, FuturePromiseFactory
TheEventExecutor
is a specialEventExecutorGroup
which comes with some handy methods to see if aThread
is executed in a event loop. Besides this, it also extends theEventExecutorGroup
to allow for a generic way to access methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
execute(Runnable task)
default boolean
inEventLoop()
CallsinEventLoop(Thread)
withThread.currentThread()
as argumentboolean
inEventLoop(Thread thread)
default Iterator<EventExecutor>
iterator()
default <V> Future<V>
newFailedFuture(Throwable cause)
Create a newFuture
which is marked as failed already.default <V> Promise<V>
newPromise()
Return a newPromise
.default <V> Future<V>
newSucceededFuture(V result)
Create a newFuture
which is marked as succeeded already.default EventExecutor
next()
Returns a reference to itself.Future<Void>
schedule(Runnable task, long delay, TimeUnit unit)
Schedule the given task for execution after the given delay, in the next availableEventExecutor
in this group, and return a future that produces anull
result when the task completes.<V> Future<V>
schedule(Callable<V> task, long delay, TimeUnit unit)
Schedule the given task for execution after the given delay, in the next availableEventExecutor
in this group, and return a future that will return the result of the callable when the task completes.Future<Void>
scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
Schedule the given task for periodic execution in the next availableEventExecutor
.Future<Void>
scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
Schedule the given task for periodic execution in the next availableEventExecutor
.Future<Void>
submit(Runnable task)
Submit the given task for execution in the next availableEventExecutor
in this group, and return a future that produces anull
result when the task completes.<T> Future<T>
submit(Runnable task, T result)
Submit the given task for execution in the next availableEventExecutor
in this group, and return a future that produces the given result when the task completes.<T> Future<T>
submit(Callable<T> task)
Submit the given task for execution in the next availableEventExecutor
in this group, and return a future that will return the result of the callable when the task completes.-
Methods inherited from interface io.netty5.util.concurrent.EventExecutorGroup
awaitTermination, isShutdown, isShuttingDown, isTerminated, shutdownGracefully, shutdownGracefully, terminationFuture
-
Methods inherited from interface io.netty5.util.concurrent.FuturePromiseFactory
newSucceededFuture
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
next
default EventExecutor next()
Returns a reference to itself.- Specified by:
next
in interfaceEventExecutorGroup
-
iterator
default Iterator<EventExecutor> iterator()
- Specified by:
iterator
in interfaceEventExecutorGroup
- Specified by:
iterator
in interfaceIterable<EventExecutor>
-
inEventLoop
default boolean inEventLoop()
CallsinEventLoop(Thread)
withThread.currentThread()
as argument
-
inEventLoop
boolean inEventLoop(Thread thread)
-
newPromise
default <V> Promise<V> newPromise()
Return a newPromise
.- Specified by:
newPromise
in interfaceFuturePromiseFactory
-
newSucceededFuture
default <V> Future<V> newSucceededFuture(V result)
Create a newFuture
which is marked as succeeded already. SoAsynchronousResult.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 interfaceFuturePromiseFactory
-
newFailedFuture
default <V> Future<V> newFailedFuture(Throwable cause)
Create a newFuture
which is marked as failed already. SoAsynchronousResult.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 interfaceFuturePromiseFactory
-
submit
Future<Void> submit(Runnable task)
Description copied from interface:EventExecutorGroup
Submit the given task for execution in the next availableEventExecutor
in this group, and return a future that produces anull
result when the task completes.- Specified by:
submit
in interfaceEventExecutorGroup
- Parameters:
task
- The task that should be executed in thisEventExecutorGroup
.- Returns:
- A future that represents the completion of the submitted task.
-
submit
<T> Future<T> submit(Runnable task, T result)
Description copied from interface:EventExecutorGroup
Submit the given task for execution in the next availableEventExecutor
in this group, and return a future that produces the given result when the task completes.- Specified by:
submit
in interfaceEventExecutorGroup
- Type Parameters:
T
- The type of the future result.- Parameters:
task
- The task that should be executed in thisEventExecutorGroup
.result
- The value that the returned future will complete with, if the task completes successfully.- Returns:
- A future that represents the completion of the submitted task.
-
submit
<T> Future<T> submit(Callable<T> task)
Description copied from interface:EventExecutorGroup
Submit the given task for execution in the next availableEventExecutor
in this group, and return a future that will return the result of the callable when the task completes.- Specified by:
submit
in interfaceEventExecutorGroup
- Type Parameters:
T
- The type of the future result.- Parameters:
task
- The task that should be executed in thisEventExecutorGroup
.- Returns:
- A future that represents the completion of the submitted task.
-
schedule
Future<Void> schedule(Runnable task, long delay, TimeUnit unit)
Description copied from interface:EventExecutorGroup
Schedule the given task for execution after the given delay, in the next availableEventExecutor
in this group, and return a future that produces anull
result when the task completes.- Specified by:
schedule
in interfaceEventExecutorGroup
- Parameters:
task
- The task that should be executed in thisEventExecutorGroup
after the given delay.delay
- A positive time delay, in the given time unit.unit
- The non-null time unit for the delay.- Returns:
- A future that represents the completion of the scheduled task.
-
schedule
<V> Future<V> schedule(Callable<V> task, long delay, TimeUnit unit)
Description copied from interface:EventExecutorGroup
Schedule the given task for execution after the given delay, in the next availableEventExecutor
in this group, and return a future that will return the result of the callable when the task completes.- Specified by:
schedule
in interfaceEventExecutorGroup
- Type Parameters:
V
- The type of the future result.- Parameters:
task
- The task that should be executed in thisEventExecutorGroup
after the given delay.delay
- A positive time delay, in the given time unit.unit
- The non-null time unit for the delay.- Returns:
- A future that represents the completion of the scheduled task.
-
scheduleAtFixedRate
Future<Void> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
Description copied from interface:EventExecutorGroup
Schedule the given task for periodic execution in the next availableEventExecutor
. The first execution will occur after the given initial delay, and the following repeated executions will occur with the given period of time between each execution is started. If the task takes longer to complete than the requested period, then the following executions will be delayed, rather than allowing multiple instances of the task to run concurrently.The task will be executed repeatedly until it either fails with an exception, or its future is cancelled. The future thus will never complete successfully.
- Specified by:
scheduleAtFixedRate
in interfaceEventExecutorGroup
- Parameters:
task
- The task that should be scheduled to execute at a fixed rate in thisEventExecutorGroup
.initialDelay
- The positive initial delay for the first task execution, in terms of the given time unit.period
- The positive period for the execution frequency to use after the first execution has started, in terms of the given time unit.unit
- The non-null time unit for the delay and period.- Returns:
- A future that represents the recurring task, and which can be cancelled to stop future executions.
-
scheduleWithFixedDelay
Future<Void> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
Description copied from interface:EventExecutorGroup
Schedule the given task for periodic execution in the next availableEventExecutor
. The first execution will occur after the given initial delay, and the following repeated executions will occur with the given subsequent delay between one task completing and the next task starting. The delay from the completion of one task, to the start of the next, stays unchanged regardless of how long a task takes to complete.This is in contrast to
EventExecutorGroup.scheduleAtFixedRate(Runnable, long, long, TimeUnit)
which varies the delays between the tasks in order to hit a given frequency.The task will be executed repeatedly until it either fails with an exception, or its future is cancelled. The future thus will never complete successfully.
- Specified by:
scheduleWithFixedDelay
in interfaceEventExecutorGroup
- Parameters:
task
- The task that should be scheduled to execute with fixed delays in thisEventExecutorGroup
.initialDelay
- The positive initial delay for the first task execution, in terms of the given time unit.delay
- The positive subsequent delay between task, to use after the first execution has completed, in terms of the given time unit.unit
- The non-null time unit for the delays.- Returns:
- A future that represents the recurring task, and which can be cancelled to stop future executions.
-
execute
void execute(Runnable task)
- Specified by:
execute
in interfaceEventExecutorGroup
- Specified by:
execute
in interfaceExecutor
-
-