Top Fields Constructors Methods
io.netty5.channel.embedded

pack-priv final Class EmbeddedEventLoop

extends AbstractScheduledEventExecutor
implements EventLoop
Class Inheritance
All Implemented Interfaces
io.netty5.channel.EventLoop, io.netty5.channel.EventLoopGroup, io.netty5.util.concurrent.EventExecutorGroup, java.util.concurrent.Executor, java.lang.Iterable, io.netty5.util.concurrent.OrderedEventExecutor, io.netty5.util.concurrent.EventExecutor, io.netty5.util.concurrent.FuturePromiseFactory
Imports
io.netty5.channel.Channel, .EventLoop, .IoHandle, io.netty5.util.concurrent.AbstractScheduledEventExecutor, .Future, .Promise, io.netty5.util.internal.StringUtil, 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().

pack-priv boolean
private long
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 non-negative maximum amount of time to wait for the executor group to terminate.
timeout
,
TimeUnit
The non-null time unit of the timeout.
unit
)

Overrides default io.netty5.util.concurrent.EventExecutorGroup.awaitTermination.

Wait for this EventExecutorGroup to terminate, up to the given timeout.
pack-priv void
private static EmbeddedChannel
cast(IoHandle handle)

public Future<Void>
deregisterForIo(IoHandle
the IoHandle to deregister.
handle
)

Implements io.netty5.channel.EventLoop.deregisterForIo.

Deregister the Channel from the EventLoop for I/O processing.
private void
deregisterForIO0(Channel channel, Promise<Void> promise)

public void
execute(Runnable
the runnable task
task
)

Overrides default io.netty5.util.concurrent.EventExecutorGroup.execute.

Implements io.netty5.util.concurrent.EventExecutor.execute.

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

Overrides io.netty5.util.concurrent.AbstractScheduledEventExecutor.getCurrentTimeNanos.

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

Implements io.netty5.util.concurrent.EventExecutor.inEventLoop.

Return true if the given Thread is executed in the event loop, false otherwise.
public boolean
isCompatible(Class<? extends IoHandle>
the type of the IoHandle.
handleType
)

Implements io.netty5.channel.EventLoop.isCompatible.

Returns true if the given type is compatible with this EventLoopGroup and so can be registered to the contained EventLoops, false otherwise.
public boolean
isShutdown()

Implements io.netty5.util.concurrent.EventExecutorGroup.isShutdown.

Returns true if all EventExecutors managed by this EventExecutorGroup have been shut down gracefully and moved past the grace period so that they are no longer accepting any new tasks.
public boolean
public boolean
isTerminated()

Overrides default io.netty5.util.concurrent.EventExecutorGroup.isTerminated.

Returns true if all EventExecutors managed by this EventExecutorGroup are shut down, and all of their tasks have completed.
public EventLoop
pack-priv long
public Future<Void>
registerForIo(IoHandle
the IoHandle to register.
handle
)

Implements io.netty5.channel.EventLoop.registerForIo.

Register the IoHandle to the EventLoop for I/O processing.
private void
pack-priv long
pack-priv void
public Future<Void>
shutdownGracefully(long
the quiet period as described in the documentation
quietPeriod
,
long
the maximum amount of time to wait until the executor is shutting down regardless if a task was submitted during the quiet period.
timeout
,
TimeUnit
the unit of quietPeriod and timeout
unit
)

Implements io.netty5.util.concurrent.EventExecutorGroup.shutdownGracefully.

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

Implements io.netty5.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.netty5.util.concurrent.AbstractScheduledEventExecutor:
cancelScheduledTaskshasScheduledTasksinitialNanoTimenanoTimenewRunnableScheduledFuturenewScheduledTaskFornextScheduledTaskNanopollScheduledTaskpollScheduledTaskschedulescheduleschedulescheduleAtFixedRatescheduleWithFixedDelay

Field Detail

frozenTimestampback to summary
private long frozenTimestamp

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

runningback to summary
pack-priv boolean running
startTimeback to summary
private long startTime
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)

Overrides default io.netty5.util.concurrent.EventExecutorGroup.awaitTermination.

Doc from io.netty5.util.concurrent.EventExecutorGroup.awaitTermination.

Wait for this EventExecutorGroup to terminate, up to the given timeout.

Parameters
timeout:long

The non-negative maximum amount of time to wait for the executor group to terminate.

unit:TimeUnit

The non-null time unit of the timeout.

Returns:boolean

true if the executor group terminated within the specific timeout.

Annotations
@Override
cancelScheduledback to summary
pack-priv void cancelScheduled()
castback to summary
private static EmbeddedChannel cast(IoHandle handle)
deregisterForIoback to summary
public Future<Void> deregisterForIo(IoHandle handle)

Implements io.netty5.channel.EventLoop.deregisterForIo.

Doc from io.netty5.channel.EventLoop.deregisterForIo.

Deregister the Channel from the EventLoop for I/O processing.

Parameters
handle:IoHandle

the IoHandle to deregister.

Returns:Future<Void>

the Future that is notified once the operations completes.

Annotations
@Override
deregisterForIO0back to summary
private void deregisterForIO0(Channel channel, Promise<Void> promise)
executeback to summary
public void execute(Runnable task)

Overrides default io.netty5.util.concurrent.EventExecutorGroup.execute.

Implements io.netty5.util.concurrent.EventExecutor.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
task:Runnable

the runnable task

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

Overrides io.netty5.util.concurrent.AbstractScheduledEventExecutor.getCurrentTimeNanos.

Doc from io.netty5.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(Thread thread)

Implements io.netty5.util.concurrent.EventExecutor.inEventLoop.

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

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

Annotations
@Override
isCompatibleback to summary
public boolean isCompatible(Class<? extends IoHandle> handleType)

Implements io.netty5.channel.EventLoop.isCompatible.

Doc from io.netty5.channel.EventLoopGroup.isCompatible.

Returns true if the given type is compatible with this EventLoopGroup and so can be registered to the contained EventLoops, false otherwise.

Parameters
handleType:Class<? extends IoHandle>

the type of the IoHandle.

Returns:boolean

if compatible of not.

Annotations
@Override
isShutdownback to summary
public boolean isShutdown()

Implements io.netty5.util.concurrent.EventExecutorGroup.isShutdown.

Doc from io.netty5.util.concurrent.EventExecutorGroup.isShutdown.

Returns true if all EventExecutors managed by this EventExecutorGroup have been shut down gracefully and moved past the grace period so that they are no longer accepting any new tasks.

An executor group that "is shut down" might still be executing tasks that it has queued up, but it will no longer be accepting any new tasks. Once all running and queued tasks have completed, the executor group will be terminated.

Returns:boolean

true if all executors in this group have shut down and are no longer accepting any new tasks.

Annotations
@Override
isShuttingDownback to summary
public boolean isShuttingDown()

Implements io.netty5.util.concurrent.EventExecutorGroup.isShuttingDown.

Doc from io.netty5.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.

An executor group that "is shutting down" can still accept new tasks for a little while (the grace period), but will eventually start rejecting new tasks. At that point, the executor group will be shut down.

Returns:boolean

true if all executors in this group have at least started shutting down, otherwise false.

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Overrides default io.netty5.util.concurrent.EventExecutorGroup.isTerminated.

Doc from io.netty5.util.concurrent.EventExecutorGroup.isTerminated.

Returns true if all EventExecutors managed by this EventExecutorGroup are shut down, and all of their tasks have completed.

Returns:boolean

true if all executors in this group have terminated.

Annotations
@Override
nextback to summary
public EventLoop next()

Overrides default io.netty5.channel.EventLoop.next, io.netty5.util.concurrent.EventExecutor.next.

Doc from io.netty5.channel.EventLoopGroup.next.

Return the next EventLoop to use

Annotations
@Override
nextScheduledTaskback to summary
pack-priv long nextScheduledTask()
registerForIoback to summary
public Future<Void> registerForIo(IoHandle handle)

Implements io.netty5.channel.EventLoop.registerForIo.

Doc from io.netty5.channel.EventLoop.registerForIo.

Register the IoHandle to the EventLoop for I/O processing.

Parameters
handle:IoHandle

the IoHandle to register.

Returns:Future<Void>

the Future that is notified once the operations completes.

Annotations
@Override
registerForIO0back to summary
private void registerForIO0(EmbeddedChannel channel, Promise<Void> promise)
runScheduledTasksback to summary
pack-priv long runScheduledTasks()
runTasksback to summary
pack-priv void runTasks()
shutdownGracefullyback to summary
public Future<Void> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit)

Implements io.netty5.util.concurrent.EventExecutorGroup.shutdownGracefully.

Doc from io.netty5.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. This method 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 shutting down regardless if a task was submitted during the quiet period.

unit:TimeUnit

the unit of quietPeriod and timeout

Returns:Future<Void>

the terminationFuture()

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

Implements io.netty5.util.concurrent.EventExecutorGroup.terminationFuture.

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

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

Returns:Future<Void>

The Future representing the termination of this EventExecutorGroup.

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