Top Description Fields Constructors Methods
io.netty.channel.epoll

public Class EpollEventLoop

extends SingleThreadEventLoop
Class Inheritance
Imports
io.netty.channel.Channel, .EventLoop, .EventLoopGroup, .EventLoopTaskQueueFactory, .SelectStrategy, .SingleThreadEventLoop, io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe, io.netty.channel.unix.FileDescriptor, .IovArray, io.netty.util.IntSupplier, io.netty.util.collection.IntObjectHashMap, .IntObjectMap, io.netty.util.concurrent.RejectedExecutionHandler, io.netty.util.internal.ObjectUtil, .PlatformDependent, .SystemPropertyUtil, .UnstableApi, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.IOException, java.util.Iterator, .Queue, java.util.concurrent.Executor, java.util.concurrent.atomic.AtomicLong

EventLoop which uses epoll under the covers. Only works on Linux!

Field Summary

Modifier and TypeField and Description
private final boolean
private static final long
private final IntObjectMap<AbstractEpollChannel>
private NativeDatagramPacketArray
private static final long
private FileDescriptor
private FileDescriptor
private final EpollEventArray
private volatile int
private IovArray
private static final InternalLogger
private static final long
private final AtomicLong
private static final long
private boolean
private final IntSupplier
private final SelectStrategy
private FileDescriptor
Inherited from io.netty.channel.SingleThreadEventLoop:
DEFAULT_MAX_PENDING_TASKS

Constructor Summary

AccessConstructor and Description
pack-priv
EpollEventLoop(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
add(AbstractEpollChannel ch)

Register the given epoll with this EventLoop.

protected boolean
protected boolean
beforeScheduledTaskSubmitted(long
deadline of the to-be-scheduled task relative to AbstractScheduledEventExecutor#getCurrentTimeNanos()
deadlineNanos
)

Overrides io.netty.util.concurrent.AbstractScheduledEventExecutor.beforeScheduledTaskSubmitted.

Called from arbitrary non-EventExecutor threads prior to scheduled task submission.
pack-priv NativeDatagramPacketArray
cleanDatagramPacketArray()

Return a cleared NativeDatagramPacketArray that can be used for writes in this EventLoop.

pack-priv IovArray
cleanIovArray()

Return a cleared IovArray that can be used for writes in this EventLoop.

protected void
cleanup()

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.cleanup.

Do nothing, sub-classes may override
private void
public void
closeFileDescriptors()

This method is intended for use by process checkpoint/restore integration, such as OpenJDK CRaC.

private int
private long
epollWait(long deadlineNanos)

private int
private int
private int
public int
getIoRatio()

Returns the percentage of the desired amount of time spent for I/O in the event loop.

pack-priv void
handleLoopException(Throwable t)

Visible only for testing!

pack-priv void
modify(AbstractEpollChannel ch)

The flags of the given epoll was modified so update the registration

private static Queue<Runnable>
protected Queue<Runnable>
newTaskQueue(int maxPendingTasks)

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.newTaskQueue.

Create a new Queue which will holds the tasks to execute.
private static Queue<Runnable>
newTaskQueue0(int maxPendingTasks)

public void
openFileDescriptors()

This method is intended for use by a process checkpoint/restore integration, such as OpenJDK CRaC.

private boolean
processReady(EpollEventArray events, int ready)

public int
registeredChannels()

Overrides io.netty.channel.SingleThreadEventLoop.registeredChannels.

Returns the number of Channels registered with this EventLoop or -1 if operation is not supported.
public Iterator<Channel>
pack-priv void
remove(AbstractEpollChannel ch)

Deregister the given epoll from this EventLoop.

protected void
run()

Implements abstract io.netty.util.concurrent.SingleThreadEventExecutor.run.

Run the tasks in the taskQueue
public void
setIoRatio(int ioRatio)

Sets the percentage of the desired amount of time spent for I/O in the event loop.

protected void
Inherited from io.netty.channel.SingleThreadEventLoop:
afterRunningAllTasksexecuteAfterEventLoopIterationhasTasksnextparentpendingTasksregisterregisterregister

Field Detail

allowGrowingback to summary
private final boolean allowGrowing
AWAKEback to summary
private static final long AWAKE
channelsback to summary
private final IntObjectMap<AbstractEpollChannel> channels
datagramPacketArrayback to summary
private NativeDatagramPacketArray datagramPacketArray
EPOLL_WAIT_MILLIS_THRESHOLDback to summary
private static final long EPOLL_WAIT_MILLIS_THRESHOLD
epollFdback to summary
private FileDescriptor epollFd
eventFdback to summary
private FileDescriptor eventFd
eventsback to summary
private final EpollEventArray events
ioRatioback to summary
private volatile int ioRatio
iovArrayback to summary
private IovArray iovArray
loggerback to summary
private static final InternalLogger logger

Hides io.netty.util.concurrent.SingleThreadEventExecutor.logger.

MAX_SCHEDULED_TIMERFD_NSback to summary
private static final long MAX_SCHEDULED_TIMERFD_NS
nextWakeupNanosback to summary
private final AtomicLong nextWakeupNanos
NONEback to summary
private static final long NONE
pendingWakeupback to summary
private boolean pendingWakeup
selectNowSupplierback to summary
private final IntSupplier selectNowSupplier
selectStrategyback to summary
private final SelectStrategy selectStrategy
timerFdback to summary
private FileDescriptor timerFd

Constructor Detail

EpollEventLoopback to summary
pack-priv EpollEventLoop(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)

Method Detail

addback to summary
pack-priv void add(AbstractEpollChannel ch) throws IOException

Register the given epoll with this EventLoop.

afterScheduledTaskSubmittedback to summary
protected boolean afterScheduledTaskSubmitted(long deadlineNanos)

Overrides io.netty.util.concurrent.AbstractScheduledEventExecutor.afterScheduledTaskSubmitted.

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

See beforeScheduledTaskSubmitted(long). Called only after that method returns false.

Parameters
deadlineNanos:long

relative to AbstractScheduledEventExecutor#getCurrentTimeNanos()

Returns:boolean

true if the EventExecutor thread should be woken, false otherwise

Annotations
@Override
beforeScheduledTaskSubmittedback to summary
protected boolean beforeScheduledTaskSubmitted(long deadlineNanos)

Overrides io.netty.util.concurrent.AbstractScheduledEventExecutor.beforeScheduledTaskSubmitted.

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

Called from arbitrary non-EventExecutor threads prior to scheduled task submission. Returns true if the EventExecutor thread should be woken immediately to process the scheduled task (if not already awake).

If false is returned, afterScheduledTaskSubmitted(long) will be called with the same value after the scheduled task is enqueued, providing another opportunity to wake the EventExecutor thread if required.

Parameters
deadlineNanos:long

deadline of the to-be-scheduled task relative to AbstractScheduledEventExecutor#getCurrentTimeNanos()

Returns:boolean

true if the EventExecutor thread should be woken, false otherwise

Annotations
@Override
cleanDatagramPacketArrayback to summary
pack-priv NativeDatagramPacketArray cleanDatagramPacketArray()

Return a cleared NativeDatagramPacketArray that can be used for writes in this EventLoop.

cleanIovArrayback to summary
pack-priv IovArray cleanIovArray()

Return a cleared IovArray that can be used for writes in this EventLoop.

cleanupback to summary
protected void cleanup()

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.cleanup.

Doc from io.netty.util.concurrent.SingleThreadEventExecutor.cleanup.

Do nothing, sub-classes may override

Annotations
@Override
closeAllback to summary
private void closeAll()
closeFileDescriptorsback to summary
public void closeFileDescriptors()

This method is intended for use by process checkpoint/restore integration, such as OpenJDK CRaC. It's up to the caller to ensure that there is no concurrent use of the FDs while these are closed, e.g. by blocking the executor.

Annotations
@UnstableApi
epollBusyWaitback to summary
private int epollBusyWait() throws IOException
epollWaitback to summary
private long epollWait(long deadlineNanos) throws IOException
epollWaitNoTimerChangeback to summary
private int epollWaitNoTimerChange() throws IOException
epollWaitNowback to summary
private int epollWaitNow() throws IOException
epollWaitTimeboxedback to summary
private int epollWaitTimeboxed() throws IOException
getIoRatioback to summary
public int getIoRatio()

Returns the percentage of the desired amount of time spent for I/O in the event loop.

handleLoopExceptionback to summary
pack-priv void handleLoopException(Throwable t)

Visible only for testing!

modifyback to summary
pack-priv void modify(AbstractEpollChannel ch) throws IOException

The flags of the given epoll was modified so update the registration

newTaskQueueback to summary
private static Queue<Runnable> newTaskQueue(EventLoopTaskQueueFactory queueFactory)
newTaskQueueback to summary
protected Queue<Runnable> newTaskQueue(int maxPendingTasks)

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.newTaskQueue.

Doc from io.netty.util.concurrent.SingleThreadEventExecutor.newTaskQueue.

Create a new Queue which will holds the tasks to execute. This default implementation will return a LinkedBlockingQueue but if your sub-class of SingleThreadEventExecutor will not do any blocking calls on the this Queue it may make sense to @Override this and return some more performant implementation that does not support blocking operations at all.

Annotations
@Override
newTaskQueue0back to summary
private static Queue<Runnable> newTaskQueue0(int maxPendingTasks)
openFileDescriptorsback to summary
public void openFileDescriptors()

This method is intended for use by a process checkpoint/restore integration, such as OpenJDK CRaC.

Annotations
@UnstableApi
processReadyback to summary
private boolean processReady(EpollEventArray events, int ready)
registeredChannelsback to summary
public int registeredChannels()

Overrides io.netty.channel.SingleThreadEventLoop.registeredChannels.

Doc from io.netty.channel.SingleThreadEventLoop.registeredChannels.

Returns the number of Channels registered with this EventLoop or -1 if operation is not supported. The returned value is not guaranteed to be exact accurate and should be viewed as a best effort.

Annotations
@Override
registeredChannelsIteratorback to summary
public Iterator<Channel> registeredChannelsIterator()

Overrides io.netty.channel.SingleThreadEventLoop.registeredChannelsIterator.

Returns:Iterator<Channel>

Doc from io.netty.channel.SingleThreadEventLoop.registeredChannelsIterator.

read-only iterator of active Channels registered with this EventLoop. The returned value is not guaranteed to be exact accurate and should be viewed as a best effort. This method is expected to be called from within event loop.

Annotations
@Override
removeback to summary
pack-priv void remove(AbstractEpollChannel ch) throws IOException

Deregister the given epoll from this EventLoop.

runback to summary
protected void run()

Implements abstract io.netty.util.concurrent.SingleThreadEventExecutor.run.

Doc from io.netty.util.concurrent.SingleThreadEventExecutor.run.

Run the tasks in the taskQueue

Annotations
@Override
setIoRatioback to summary
public void setIoRatio(int ioRatio)

Sets the percentage of the desired amount of time spent for I/O in the event loop. The default value is 50, which means the event loop will try to spend the same amount of time for I/O as for non-I/O tasks.

wakeupback to summary
protected void wakeup(boolean inEventLoop)

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.wakeup.

Annotations
@Override