Top Description Inners Fields Constructors Methods
io.netty.util.concurrent

public abstract Class AbstractEventExecutor

extends AbstractExecutorService
implements EventExecutor
Class Inheritance
All Implemented Interfaces
io.netty.util.concurrent.EventExecutor, io.netty.util.concurrent.EventExecutorGroup, java.lang.Iterable, java.util.concurrent.ScheduledExecutorService, java.util.concurrent.ExecutorService, java.lang.AutoCloseable, java.util.concurrent.Executor
Known Direct Subclasses
io.netty.util.concurrent.AbstractScheduledEventExecutor, io.netty.util.concurrent.ImmediateEventExecutor, io.netty.util.concurrent.NonStickyEventExecutorGroup.NonStickyOrderedEventExecutor
Imports
io.netty.util.internal.UnstableApi, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, org.jetbrains.annotations.Async.Execute, java.util.Collection, .Collections, .Iterator, .List, java.util.concurrent.AbstractExecutorService, .Callable, .RunnableFuture, .TimeUnit

Abstract base class for EventExecutor implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AbstractEventExecutor.LazyRunnable

Deprecated override SingleThreadEventExecutor#wakesUpForTask to re-create this behaviour

Field Summary

Modifier and TypeField and Description
pack-priv static final long
pack-priv static final long
private static final InternalLogger
private final EventExecutorGroup
private final Collection<EventExecutor>

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
public boolean
public Iterator<EventExecutor>
iterator()

Implements io.netty.util.concurrent.EventExecutorGroup.iterator.

Returns an iterator over elements of type T.
public void
lazyExecute(Runnable task)

Like 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.

public <V> Future<V>
newFailedFuture(Throwable cause)

Implements io.netty.util.concurrent.EventExecutor.newFailedFuture.

Create a new Future which is marked as failed already.
public <V> ProgressivePromise<V>
public <V> Promise<V>
public <V> Future<V>
newSucceededFuture(V result)

Implements io.netty.util.concurrent.EventExecutor.newSucceededFuture.

Create a new Future which is marked as succeeded already.
protected final <T> RunnableFuture<T>
newTaskFor(Runnable
the runnable task being wrapped
runnable
,
T
the default value for the returned future
value
)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given runnable and default value.
protected final <T> RunnableFuture<T>
newTaskFor(Callable<T>
the callable task being wrapped
callable
)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given callable task.
public EventExecutor
next()

Implements io.netty.util.concurrent.EventExecutor.next.

Returns a reference to itself.
public EventExecutorGroup
parent()

Implements io.netty.util.concurrent.EventExecutor.parent.

Return the EventExecutorGroup which is the parent of this EventExecutor,
protected static void
protected static void
safeExecute(Runnable task)

Try to execute the given Runnable and just log if it throws a Throwable.

public ScheduledFuture<?>
schedule(Runnable
the task to execute
command
,
long
the time from now to delay execution
delay
,
TimeUnit
the time unit of the delay parameter
unit
)

Implements io.netty.util.concurrent.EventExecutorGroup.schedule.

Submits a one-shot task that becomes enabled after the given delay.
public <V> ScheduledFuture<V>
schedule(Callable<V>
the function to execute
callable
,
long
the time from now to delay execution
delay
,
TimeUnit
the time unit of the delay parameter
unit
)

Implements io.netty.util.concurrent.EventExecutorGroup.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.
public ScheduledFuture<?>
scheduleAtFixedRate(Runnable
the task to execute
command
,
long
the time to delay first execution
initialDelay
,
long
the period between successive executions
period
,
TimeUnit
the time unit of the initialDelay and period parameters
unit
)

Implements io.netty.util.concurrent.EventExecutorGroup.scheduleAtFixedRate.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after initialDelay, then initialDelay + period, then initialDelay + 2 * period, and so on.
public ScheduledFuture<?>
scheduleWithFixedDelay(Runnable
the task to execute
command
,
long
the time to delay first execution
initialDelay
,
long
the delay between the termination of one execution and the commencement of the next
delay
,
TimeUnit
the time unit of the initialDelay and delay parameters
unit
)

Implements io.netty.util.concurrent.EventExecutorGroup.scheduleWithFixedDelay.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.
public abstract void
shutdown()

Redeclares io.netty.util.concurrent.EventExecutorGroup.shutdown, java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
public Future<?>
public List<Runnable>
shutdownNow()

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownNow, java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
public Future<?>
submit(Runnable
the task to submit
task
)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements io.netty.util.concurrent.EventExecutorGroup.submit, java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public <T> Future<T>
submit(Runnable
the task to submit
task
,
T
the result to return
result
)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements io.netty.util.concurrent.EventExecutorGroup.submit, java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public <T> Future<T>
submit(Callable<T>
the task to submit
task
)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements io.netty.util.concurrent.EventExecutorGroup.submit, java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task.
Inherited from java.util.concurrent.AbstractExecutorService:
invokeAllinvokeAllinvokeAnyinvokeAny

Field Detail

DEFAULT_SHUTDOWN_QUIET_PERIODback to summary
pack-priv static final long DEFAULT_SHUTDOWN_QUIET_PERIOD
DEFAULT_SHUTDOWN_TIMEOUTback to summary
pack-priv static final long DEFAULT_SHUTDOWN_TIMEOUT
loggerback to summary
private static final InternalLogger logger
parentback to summary
private final EventExecutorGroup parent
selfCollectionback to summary
private final Collection<EventExecutor> selfCollection

Constructor Detail

AbstractEventExecutorback to summary
protected AbstractEventExecutor()
AbstractEventExecutorback to summary
protected AbstractEventExecutor(EventExecutorGroup parent)

Method Detail

inEventLoopback to summary
public boolean inEventLoop()

Implements io.netty.util.concurrent.EventExecutor.inEventLoop.

Doc from io.netty.util.concurrent.EventExecutor.inEventLoop.

Calls inEventLoop(Thread) with Thread#currentThread() as argument

Annotations
@Override
iteratorback to summary
public Iterator<EventExecutor> iterator()

Implements io.netty.util.concurrent.EventExecutorGroup.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<EventExecutor>

an Iterator.

Annotations
@Override
lazyExecuteback to summary
public void lazyExecute(Runnable task)

Like 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.

The default implementation just delegates to execute(Runnable).

Annotations
@UnstableApi
newFailedFutureback to summary
public <V> Future<V> newFailedFuture(Throwable cause)

Implements io.netty.util.concurrent.EventExecutor.newFailedFuture.

Doc from io.netty.util.concurrent.EventExecutor.newFailedFuture.

Create a new Future which is marked as failed already. So Future#isSuccess() will return false. All FutureListener added to it will be notified directly. Also every call of blocking methods will just return without blocking.

Annotations
@Override
newProgressivePromiseback to summary
public <V> ProgressivePromise<V> newProgressivePromise()

Implements io.netty.util.concurrent.EventExecutor.newProgressivePromise.

Doc from io.netty.util.concurrent.EventExecutor.newProgressivePromise.

Create a new ProgressivePromise.

Annotations
@Override
newPromiseback to summary
public <V> Promise<V> newPromise()

Implements io.netty.util.concurrent.EventExecutor.newPromise.

Doc from io.netty.util.concurrent.EventExecutor.newPromise.

Return a new Promise.

Annotations
@Override
newSucceededFutureback to summary
public <V> Future<V> newSucceededFuture(V result)

Implements io.netty.util.concurrent.EventExecutor.newSucceededFuture.

Doc from io.netty.util.concurrent.EventExecutor.newSucceededFuture.

Create a new Future which is marked as succeeded already. So Future#isSuccess() will return true. All FutureListener added to it will be notified directly. Also every call of blocking methods will just return without blocking.

Annotations
@Override
newTaskForback to summary
protected final <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Doc from java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given runnable and default value.

Parameters
<T>
the type of the given value
runnable:Runnable

the runnable task being wrapped

value:T

the default value for the returned future

Returns:RunnableFuture<T>

a RunnableFuture which, when run, will run the underlying runnable and which, as a Future, will yield the given value as its result and provide for cancellation of the underlying task

Annotations
@Override
newTaskForback to summary
protected final <T> RunnableFuture<T> newTaskFor(Callable<T> callable)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Doc from java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given callable task.

Parameters
<T>
the type of the callable's result
callable:Callable<T>

the callable task being wrapped

Returns:RunnableFuture<T>

a RunnableFuture which, when run, will call the underlying callable and which, as a Future, will yield the callable's result as its result and provide for cancellation of the underlying task

Annotations
@Override
nextback to summary
public EventExecutor next()

Implements io.netty.util.concurrent.EventExecutor.next.

Doc from io.netty.util.concurrent.EventExecutor.next.

Returns a reference to itself.

Annotations
@Override
parentback to summary
public EventExecutorGroup parent()

Implements io.netty.util.concurrent.EventExecutor.parent.

Doc from io.netty.util.concurrent.EventExecutor.parent.

Return the EventExecutorGroup which is the parent of this EventExecutor,

Annotations
@Override
runTaskback to summary
protected static void runTask(Runnable task)
safeExecuteback to summary
protected static void safeExecute(Runnable task)

Try to execute the given Runnable and just log if it throws a Throwable.

scheduleback to summary
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)

Implements io.netty.util.concurrent.EventExecutorGroup.schedule.

Doc from java.util.concurrent.ScheduledExecutorService.schedule.

Submits a one-shot task that becomes enabled after the given delay.

Parameters
command:Runnable

the task to execute

delay:long

the time from now to delay execution

unit:TimeUnit

the time unit of the delay parameter

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion

Annotations
@Override
scheduleback to summary
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)

Implements io.netty.util.concurrent.EventExecutorGroup.schedule.

Doc from java.util.concurrent.ScheduledExecutorService.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.

Parameters
<V>
the type of the callable's result
callable:Callable<V>

the function to execute

delay:long

the time from now to delay execution

unit:TimeUnit

the time unit of the delay parameter

Returns:ScheduledFuture<V>

a ScheduledFuture that can be used to extract result or cancel

Annotations
@Override
scheduleAtFixedRateback to summary
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)

Implements io.netty.util.concurrent.EventExecutorGroup.scheduleAtFixedRate.

Doc from java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after initialDelay, then initialDelay + period, then initialDelay + 2 * period, and so on.

The sequence of task executions continues indefinitely until one of the following exceptional completions occur:

  • The task is explicitly cancelled via the returned future.
  • The executor terminates, also resulting in task cancellation.
  • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.

If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

Parameters
command:Runnable

the task to execute

initialDelay:long

the time to delay first execution

period:long

the period between successive executions

unit:TimeUnit

the time unit of the initialDelay and period parameters

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.

Annotations
@Override
scheduleWithFixedDelayback to summary
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)

Implements io.netty.util.concurrent.EventExecutorGroup.scheduleWithFixedDelay.

Doc from java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay.

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.

The sequence of task executions continues indefinitely until one of the following exceptional completions occur:

  • The task is explicitly cancelled via the returned future.
  • The executor terminates, also resulting in task cancellation.
  • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.
Parameters
command:Runnable

the task to execute

initialDelay:long

the time to delay first execution

delay:long

the delay between the termination of one execution and the commencement of the next

unit:TimeUnit

the time unit of the initialDelay and delay parameters

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.

Annotations
@Override
shutdownback to summary
public abstract void shutdown()

Redeclares io.netty.util.concurrent.EventExecutorGroup.shutdown, java.util.concurrent.ExecutorService.shutdown.

Doc from java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.

This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

Annotations
@Override
@Deprecated
shutdownGracefullyback to summary
public Future<?> shutdownGracefully()

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

Doc from io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

Shortcut method for shutdownGracefully(long, long, TimeUnit) with sensible default values.

Returns:Future<?>

the terminationFuture()

Annotations
@Override
shutdownNowback to summary
public List<Runnable> shutdownNow()

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownNow, java.util.concurrent.ExecutorService.shutdownNow.

Doc from java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that.

There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. For example, typical implementations will cancel via Thread#interrupt, so any task that fails to respond to interrupts may never terminate.

Returns:List<Runnable>

list of tasks that never commenced execution

Annotations
@Override
@Deprecated
submitback to summary
public Future<?> submit(Runnable task)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements io.netty.util.concurrent.EventExecutorGroup.submit, java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.

Parameters
task:Runnable

the task to submit

Returns:Future<?>

a Future representing pending completion of the task

Annotations
@Override
submitback to summary
public <T> Future<T> submit(Runnable task, T result)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements io.netty.util.concurrent.EventExecutorGroup.submit, java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.

Parameters
<T>
the type of the result
task:Runnable

the task to submit

result:T

the result to return

Returns:Future<T>

a Future representing pending completion of the task

Annotations
@Override
submitback to summary
public <T> Future<T> submit(Callable<T> task)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements io.netty.util.concurrent.EventExecutorGroup.submit, java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

Note

The Executors class includes a set of methods that can convert some other common closure-like objects, for example, java.security.PrivilegedAction to Callable form so they can be submitted.

Parameters
<T>
the type of the task's result
task:Callable<T>

the task to submit

Returns:Future<T>

a Future representing pending completion of the task

Annotations
@Override
io.netty.util.concurrent back to summary

public Interface AbstractEventExecutor.LazyRunnable

extends Runnable
Known Direct Subinterfaces
io.netty.util.concurrent.SingleThreadEventExecutor.NonWakeupRunnable
Annotations
@Deprecated

Deprecated

override SingleThreadEventExecutor#wakesUpForTask to re-create this behaviour

Method Summary

Inherited from java.lang.Runnable:
run