- java.lang.Object
-
- io.netty5.util.concurrent.AbstractEventExecutor
-
- All Implemented Interfaces:
EventExecutor
,EventExecutorGroup
,FuturePromiseFactory
,Iterable<EventExecutor>
,Executor
- Direct Known Subclasses:
AbstractScheduledEventExecutor
,ImmediateEventExecutor
public abstract class AbstractEventExecutor extends Object implements EventExecutor
Abstract base class forEventExecutor
implementations.
-
-
Constructor Summary
Constructors Constructor Description AbstractEventExecutor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> Future<V>
newSucceededFuture(V result)
Create a newFuture
which is marked as succeeded already.protected <T> RunnableFuture<T>
newTaskFor(Runnable runnable, T value)
Decorate the givenRunnable
and its return value, as aRunnableFuture
, such that the returnedRunnableFuture
completes with the given result at the end of executing itsRunnable.run()
method.protected <T> RunnableFuture<T>
newTaskFor(Callable<T> callable)
Decorate the givenCallable
and its return value, as aRunnableFuture
, such that the returnedRunnableFuture
completes with the returned result from theCallable
at the end of executing itsRunnable.run()
method.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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.util.concurrent.EventExecutor
execute, inEventLoop, inEventLoop, iterator, newFailedFuture, newPromise, next, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay
-
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
-
newSucceededFuture
public <V> Future<V> newSucceededFuture(V result)
Description copied from interface:EventExecutor
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 interfaceEventExecutor
- Specified by:
newSucceededFuture
in interfaceFuturePromiseFactory
-
submit
public final 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 interfaceEventExecutor
- 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
public final <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 interfaceEventExecutor
- 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
public final <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 interfaceEventExecutor
- 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.
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
Decorate the givenRunnable
and its return value, as aRunnableFuture
, such that the returnedRunnableFuture
completes with the given result at the end of executing itsRunnable.run()
method.The returned
RunnableFuture
is the task that will actually be run by a thread in this executor.This method can be overridden by sub-classes to hook into the life cycle of the given task.
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
Decorate the givenCallable
and its return value, as aRunnableFuture
, such that the returnedRunnableFuture
completes with the returned result from theCallable
at the end of executing itsRunnable.run()
method.The returned
RunnableFuture
is the task that will actually be run by a thread in this executor.This method can be overridden by sub-classes to hook into the life cycle of the given task.
-
-