Top Fields Constructors Methods
io.netty.channel.embedded

pack-priv final Class EmbeddedEventLoop

extends AbstractScheduledEventExecutor
implements EventLoop
Class Inheritance
All Implemented Interfaces
io.netty.channel.EventLoop, io.netty.channel.EventLoopGroup, io.netty.util.concurrent.EventExecutorGroup, java.lang.Iterable, java.util.concurrent.ScheduledExecutorService, java.util.concurrent.ExecutorService, java.lang.AutoCloseable, java.util.concurrent.Executor, io.netty.util.concurrent.OrderedEventExecutor, io.netty.util.concurrent.EventExecutor
Imports
io.netty.channel.Channel, .ChannelFuture, .ChannelPromise, .DefaultChannelPromise, .EventLoop, .EventLoopGroup, io.netty.util.concurrent.AbstractScheduledEventExecutor, .Future, io.netty.util.internal.ObjectUtil, java.util.ArrayDeque, .Queue, java.util.concurrent.TimeUnit

Field Summary

Modifier and TypeField and Description
private long
frozenTimestamp

When time is frozen, the timestamp returned by getCurrentTimeNanos().

private long
startTime

When time is not frozen, the base time to subtract from System#nanoTime().

private final Queue<Runnable>
private boolean
timeFrozen

Whether time is currently frozen.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
advanceTimeBy(long nanos)

public boolean
awaitTermination(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
protected void
public void
execute(Runnable
the runnable task
command
)

Implements java.util.concurrent.Executor.execute.

Executes the given command at some time in the future.
pack-priv void
protected long
getCurrentTimeNanos()

Overrides io.netty.util.concurrent.AbstractScheduledEventExecutor.getCurrentTimeNanos.

Get the current time in nanoseconds by this executor's clock.
pack-priv boolean
public boolean
public boolean
inEventLoop(Thread thread)

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

Return true if the given Thread is executed in the event loop, false otherwise.
public boolean
isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.
public boolean
public boolean
isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down.
public EventLoop
pack-priv long
public EventLoopGroup
public ChannelFuture
public ChannelFuture
public ChannelFuture
register(Channel channel, ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Deprecated
Register a Channel with this EventLoop.
pack-priv long
pack-priv void
public void
shutdown()

Implements abstract io.netty.util.concurrent.AbstractEventExecutor.shutdown.

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

Deprecated
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
public Future<?>
shutdownGracefully(long
the quiet period as described in the documentation
quietPeriod
,
long
the maximum amount of time to wait until the executor is shutdown() regardless if a task was submitted during the quiet period
timeout
,
TimeUnit
the unit of quietPeriod and timeout
unit
)

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

Signals this executor that the caller wants the executor to be shut down.
public Future<?>
terminationFuture()

Implements io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.
pack-priv void
Inherited from io.netty.util.concurrent.AbstractScheduledEventExecutor:
afterScheduledTaskSubmittedbeforeScheduledTaskSubmitteddeadlineToDelayNanoshasScheduledTasksinitialNanoTimenanoTimenextScheduledTaskDeadlineNanosnextScheduledTaskNanopollScheduledTaskpollScheduledTaskscheduleschedulescheduleAtFixedRatescheduleWithFixedDelayvalidateScheduled

Field Detail

frozenTimestampback to summary
private long frozenTimestamp

When time is frozen, the timestamp returned by getCurrentTimeNanos(). When unfrozen, this is unused.

startTimeback to summary
private long startTime

When time is not frozen, the base time to subtract from System#nanoTime(). When time is frozen, this variable is unused. Initialized to initialNanoTime() so that until one of the time mutator methods is called, getCurrentTimeNanos() matches the default behavior.

tasksback to summary
private final Queue<Runnable> tasks
timeFrozenback to summary
private boolean timeFrozen

Whether time is currently frozen.

Constructor Detail

EmbeddedEventLoopback to summary
pack-priv EmbeddedEventLoop()

Method Detail

advanceTimeByback to summary
pack-priv void advanceTimeBy(long nanos)
awaitTerminationback to summary
public boolean awaitTermination(long timeout, TimeUnit unit)

Implements java.util.concurrent.ExecutorService.awaitTermination.

Doc from java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:boolean

true if this executor terminated and false if the timeout elapsed before termination

Annotations
@Override
cancelScheduledTasksback to summary
protected void cancelScheduledTasks()

Overrides io.netty.util.concurrent.AbstractScheduledEventExecutor.cancelScheduledTasks.

Doc from io.netty.util.concurrent.AbstractScheduledEventExecutor.cancelScheduledTasks.

Cancel all scheduled tasks. This method MUST be called only when inEventLoop() is true.

Annotations
@Override
executeback to summary
public void execute(Runnable command)

Implements java.util.concurrent.Executor.execute.

Doc from java.util.concurrent.Executor.execute.

Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

Parameters
command:Runnable

the runnable task

Annotations
@Override
freezeTimeback to summary
pack-priv void freezeTime()
getCurrentTimeNanosback to summary
protected long getCurrentTimeNanos()

Overrides io.netty.util.concurrent.AbstractScheduledEventExecutor.getCurrentTimeNanos.

Doc from io.netty.util.concurrent.AbstractScheduledEventExecutor.getCurrentTimeNanos.

Get the current time in nanoseconds by this executor's clock. This is not the same as System#nanoTime() for two reasons:

  • We apply a fixed offset to the nanoTime
  • Implementations (in particular EmbeddedEventLoop) may use their own time source so they can control time for testing purposes.
Annotations
@Override
hasPendingNormalTasksback to summary
pack-priv boolean hasPendingNormalTasks()
inEventLoopback to summary
public boolean inEventLoop()

Overrides io.netty.util.concurrent.AbstractEventExecutor.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
inEventLoopback to summary
public boolean inEventLoop(Thread thread)

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

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

Return true if the given Thread is executed in the event loop, false otherwise.

Annotations
@Override
isShutdownback to summary
public boolean isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Doc from java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.

Returns:boolean

true if this executor has been shut down

Annotations
@Override
isShuttingDownback to summary
public boolean isShuttingDown()

Implements io.netty.util.concurrent.EventExecutorGroup.isShuttingDown.

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

Returns true if and only if all EventExecutors managed by this EventExecutorGroup are being shut down gracefully or was shut down.

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Doc from java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down. Note that isTerminated is never true unless either shutdown or shutdownNow was called first.

Returns:boolean

true if all tasks have completed following shut down

Annotations
@Override
nextback to summary
public EventLoop next()

Overrides io.netty.util.concurrent.AbstractEventExecutor.next.

Implements io.netty.util.concurrent.EventExecutor.next, io.netty.channel.EventLoopGroup.next.

Doc from io.netty.channel.EventLoopGroup.next.

Return the next EventLoop to use

Annotations
@Override
nextScheduledTaskback to summary
pack-priv long nextScheduledTask()
parentback to summary
public EventLoopGroup parent()

Overrides io.netty.util.concurrent.AbstractEventExecutor.parent.

Implements io.netty.channel.EventLoop.parent, 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
registerback to summary
public ChannelFuture register(Channel channel)

Implements io.netty.channel.EventLoopGroup.register.

Doc from io.netty.channel.EventLoopGroup.register.

Register a Channel with this EventLoop. The returned ChannelFuture will get notified once the registration was complete.

Annotations
@Override
registerback to summary
public ChannelFuture register(ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Doc from io.netty.channel.EventLoopGroup.register.

Register a Channel with this EventLoop using a ChannelFuture. The passed ChannelFuture will get notified once the registration was complete and also will get returned.

Annotations
@Override
registerback to summary
public ChannelFuture register(Channel channel, ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Doc from io.netty.channel.EventLoopGroup.register.

Deprecated

Register a Channel with this EventLoop. The passed ChannelFuture will get notified once the registration was complete and also will get returned.

Annotations
@Deprecated
@Override
runScheduledTasksback to summary
pack-priv long runScheduledTasks()
runTasksback to summary
pack-priv void runTasks()
shutdownback to summary
public void shutdown()

Implements abstract io.netty.util.concurrent.AbstractEventExecutor.shutdown.

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

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

Deprecated

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(long quietPeriod, long timeout, TimeUnit unit)

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

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

Signals this executor that the caller wants the executor to be shut down. Once this method is called, isShuttingDown() starts to return true, and the executor prepares to shut itself down. Unlike shutdown(), graceful shutdown ensures that no tasks are submitted for 'the quiet period' (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period, it is guaranteed to be accepted and the quiet period will start over.

Parameters
quietPeriod:long

the quiet period as described in the documentation

timeout:long

the maximum amount of time to wait until the executor is shutdown() regardless if a task was submitted during the quiet period

unit:TimeUnit

the unit of quietPeriod and timeout

Returns:Future<?>

the terminationFuture()

Annotations
@Override
terminationFutureback to summary
public Future<?> terminationFuture()

Implements io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

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

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.

Annotations
@Override
unfreezeTimeback to summary
pack-priv void unfreezeTime()