-
- 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
TheEventExecutoris a specialEventExecutorGroupwhich comes with some handy methods to see if aThreadis executed in a event loop. Besides this, it also extends theEventExecutorGroupto allow for a generic way to access methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidexecute(Runnable task)default booleaninEventLoop()CallsinEventLoop(Thread)withThread.currentThread()as argumentbooleaninEventLoop(Thread thread)default Iterator<EventExecutor>iterator()default <V> Future<V>newFailedFuture(Throwable cause)Create a newFuturewhich is marked as failed already.default <V> Promise<V>newPromise()Return a newPromise.default <V> Future<V>newSucceededFuture(V result)Create a newFuturewhich is marked as succeeded already.default EventExecutornext()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 availableEventExecutorin this group, and return a future that produces anullresult 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 availableEventExecutorin 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 availableEventExecutorin this group, and return a future that produces anullresult when the task completes.<T> Future<T>submit(Runnable task, T result)Submit the given task for execution in the next availableEventExecutorin 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 availableEventExecutorin 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:
nextin interfaceEventExecutorGroup
-
iterator
default Iterator<EventExecutor> iterator()
- Specified by:
iteratorin interfaceEventExecutorGroup- Specified by:
iteratorin 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:
newPromisein interfaceFuturePromiseFactory
-
newSucceededFuture
default <V> Future<V> newSucceededFuture(V result)
Create a newFuturewhich is marked as succeeded already. SoAsynchronousResult.isSuccess()will returntrue. AllFutureListeneradded to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuturein interfaceFuturePromiseFactory
-
newFailedFuture
default <V> Future<V> newFailedFuture(Throwable cause)
Create a newFuturewhich is marked as failed already. SoAsynchronousResult.isSuccess()will returnfalse. AllFutureListeneradded to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuturein interfaceFuturePromiseFactory
-
submit
Future<Void> submit(Runnable task)
Description copied from interface:EventExecutorGroupSubmit the given task for execution in the next availableEventExecutorin this group, and return a future that produces anullresult when the task completes.- Specified by:
submitin 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:EventExecutorGroupSubmit the given task for execution in the next availableEventExecutorin this group, and return a future that produces the given result when the task completes.- Specified by:
submitin 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:EventExecutorGroupSubmit the given task for execution in the next availableEventExecutorin this group, and return a future that will return the result of the callable when the task completes.- Specified by:
submitin 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:EventExecutorGroupSchedule the given task for execution after the given delay, in the next availableEventExecutorin this group, and return a future that produces anullresult when the task completes.- Specified by:
schedulein interfaceEventExecutorGroup- Parameters:
task- The task that should be executed in thisEventExecutorGroupafter 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:EventExecutorGroupSchedule the given task for execution after the given delay, in the next availableEventExecutorin this group, and return a future that will return the result of the callable when the task completes.- Specified by:
schedulein interfaceEventExecutorGroup- Type Parameters:
V- The type of the future result.- Parameters:
task- The task that should be executed in thisEventExecutorGroupafter 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:EventExecutorGroupSchedule 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:
scheduleAtFixedRatein 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:EventExecutorGroupSchedule 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:
scheduleWithFixedDelayin 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:
executein interfaceEventExecutorGroup- Specified by:
executein interfaceExecutor
-
-