- 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 forEventExecutorimplementations.
-
-
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 newFuturewhich is marked as succeeded already.protected <T> RunnableFuture<T>newTaskFor(Runnable runnable, T value)Decorate the givenRunnableand its return value, as aRunnableFuture, such that the returnedRunnableFuturecompletes with the given result at the end of executing itsRunnable.run()method.protected <T> RunnableFuture<T>newTaskFor(Callable<T> callable)Decorate the givenCallableand its return value, as aRunnableFuture, such that the returnedRunnableFuturecompletes with the returned result from theCallableat the end of executing itsRunnable.run()method.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 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:EventExecutorCreate 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 interfaceEventExecutor- Specified by:
newSucceededFuturein interfaceFuturePromiseFactory
-
submit
public final 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 interfaceEventExecutor- 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
public final <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 interfaceEventExecutor- 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
public final <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 interfaceEventExecutor- 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.
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
Decorate the givenRunnableand its return value, as aRunnableFuture, such that the returnedRunnableFuturecompletes with the given result at the end of executing itsRunnable.run()method.The returned
RunnableFutureis 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 givenCallableand its return value, as aRunnableFuture, such that the returnedRunnableFuturecompletes with the returned result from theCallableat the end of executing itsRunnable.run()method.The returned
RunnableFutureis 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.
-
-