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

public Class EpollHandler

extends Object
implements IoHandler
Class Inheritance
All Implemented Interfaces
io.netty5.channel.IoHandler
Imports
io.netty5.channel.DefaultSelectStrategyFactory, .IoExecutionContext, .IoHandle, .IoHandler, .IoHandlerFactory, .SelectStrategy, .SelectStrategyFactory, .SingleThreadEventLoop, io.netty5.channel.unix.FileDescriptor, .IovArray, io.netty5.util.collection.IntObjectHashMap, .IntObjectMap, io.netty5.util.internal.StringUtil, .SystemPropertyUtil, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.IOException, .UncheckedIOException, java.util.concurrent.atomic.AtomicLong, java.util.function.IntSupplier

IoHandler 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 final FileDescriptor
private final FileDescriptor
private final EpollEventArray
private IovArray
private static final InternalLogger
private static final long
private final AtomicLong
private static final long
private boolean
private long
private final IntSupplier
private final SelectStrategy
private final FileDescriptor

Constructor Summary

AccessConstructor and Description
private
pack-priv
EpollHandler(int maxEvents, SelectStrategy strategy)

Method Summary

Modifier and TypeMethod and Description
private void
add(AbstractEpollChannel<?> ch)

Register the given channel with this EpollHandler.

private static AbstractEpollChannel<?>
cast(IoHandle handle)

private NativeDatagramPacketArray
private IovArray
public final void
deregister(IoHandle
the IoHandle to deregister..
handle
)

Implements io.netty5.channel.IoHandler.deregister.

Deregister a IoHandle for IO.
public final void
destroy()

Implements io.netty5.channel.IoHandler.destroy.

Destroy the IoHandler and free all its resources.
private int
private long
epollWait(IoExecutionContext context, long deadlineNanos)

private int
private int
private int
pack-priv void
handleLoopException(Throwable t)

Visible only for testing!

public boolean
isCompatible(Class<? extends IoHandle>
the type of the IoHandle.
handleType
)

Implements io.netty5.channel.IoHandler.isCompatible.

Returns true if the given type is compatible with this IoHandler and so can be registered, false otherwise.
private void
modify(AbstractEpollChannel<?> ch)

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

public static IoHandlerFactory
newFactory()

Returns a new IoHandlerFactory that creates EpollHandler instances.

public static IoHandlerFactory
newFactory(final int maxEvents, final SelectStrategyFactory selectStrategyFactory)

Returns a new IoHandlerFactory that creates EpollHandler instances.

public void
private boolean
processReady(EpollEventArray events, int ready)

public final void
register(IoHandle
the Channel to register..
handle
)

Implements io.netty5.channel.IoHandler.register.

Register a Channel for IO.
private void
remove(AbstractEpollChannel<?> ch)

Deregister the given channel from this EpollHandler.

public final int
run(IoExecutionContext context)

Implements io.netty5.channel.IoHandler.run.

Run the IO handled by this IoHandler.
public final void
wakeup(boolean inEventLoop)

Implements io.netty5.channel.IoHandler.wakeup.

Wakeup the IoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

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 final FileDescriptor epollFd
eventFdback to summary
private final FileDescriptor eventFd
eventsback to summary
private final EpollEventArray events
iovArrayback to summary
private IovArray iovArray
loggerback to summary
private static final InternalLogger 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
prevDeadlineNanosback to summary
private long prevDeadlineNanos
selectNowSupplierback to summary
private final IntSupplier selectNowSupplier
selectStrategyback to summary
private final SelectStrategy selectStrategy
timerFdback to summary
private final FileDescriptor timerFd

Constructor Detail

EpollHandlerback to summary
private EpollHandler()
EpollHandlerback to summary
pack-priv EpollHandler(int maxEvents, SelectStrategy strategy)

Method Detail

addback to summary
private void add(AbstractEpollChannel<?> ch) throws IOException

Register the given channel with this EpollHandler.

castback to summary
private static AbstractEpollChannel<?> cast(IoHandle handle)
cleanDatagramPacketArrayback to summary
private NativeDatagramPacketArray cleanDatagramPacketArray()
cleanIovArrayback to summary
private IovArray cleanIovArray()
deregisterback to summary
public final void deregister(IoHandle handle) throws Exception

Implements io.netty5.channel.IoHandler.deregister.

Doc from io.netty5.channel.IoHandler.deregister.

Deregister a IoHandle for IO.

Parameters
handle:IoHandle

the IoHandle to deregister..

Annotations
@Override
Exceptions
Exception:
thrown if an error happens during deregistration.
destroyback to summary
public final void destroy()

Implements io.netty5.channel.IoHandler.destroy.

Doc from io.netty5.channel.IoHandler.destroy.

Destroy the IoHandler and free all its resources.

Annotations
@Override
epollBusyWaitback to summary
private int epollBusyWait() throws IOException
epollWaitback to summary
private long epollWait(IoExecutionContext context, 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
handleLoopExceptionback to summary
pack-priv void handleLoopException(Throwable t)

Visible only for testing!

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

Implements io.netty5.channel.IoHandler.isCompatible.

Doc from io.netty5.channel.IoHandler.isCompatible.

Returns true if the given type is compatible with this IoHandler and so can be registered, false otherwise.

Parameters
handleType:Class<? extends IoHandle>

the type of the IoHandle.

Returns:boolean

if compatible of not.

Annotations
@Override
modifyback to summary
private void modify(AbstractEpollChannel<?> ch) throws IOException

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

newFactoryback to summary
public static IoHandlerFactory newFactory()

Returns a new IoHandlerFactory that creates EpollHandler instances.

newFactoryback to summary
public static IoHandlerFactory newFactory(final int maxEvents, final SelectStrategyFactory selectStrategyFactory)

Returns a new IoHandlerFactory that creates EpollHandler instances.

prepareToDestroyback to summary
public void prepareToDestroy()

Implements io.netty5.channel.IoHandler.prepareToDestroy.

Doc from io.netty5.channel.IoHandler.prepareToDestroy.

Prepare to destroy this IoHandler. This method will be called before destroy() and may be called multiple times.

Annotations
@Override
processReadyback to summary
private boolean processReady(EpollEventArray events, int ready)
registerback to summary
public final void register(IoHandle handle) throws Exception

Implements io.netty5.channel.IoHandler.register.

Doc from io.netty5.channel.IoHandler.register.

Register a Channel for IO.

Parameters
handle:IoHandle

the Channel to register..

Annotations
@Override
Exceptions
Exception:
thrown if an error happens during registration.
removeback to summary
private void remove(AbstractEpollChannel<?> ch) throws IOException

Deregister the given channel from this EpollHandler.

runback to summary
public final int run(IoExecutionContext context)

Implements io.netty5.channel.IoHandler.run.

Doc from io.netty5.channel.IoHandler.run.

Run the IO handled by this IoHandler. The IoExecutionContext should be used to ensure we not execute too long and so block the processing of other task that are scheduled on the EventLoop. This is done by taking IoExecutionContext#delayNanos(long) or IoExecutionContext#deadlineNanos() into account.

Returns:int

the number of IoHandle for which I/O was handled.

Annotations
@Override
wakeupback to summary
public final void wakeup(boolean inEventLoop)

Implements io.netty5.channel.IoHandler.wakeup.

Doc from io.netty5.channel.IoHandler.wakeup.

Wakeup the IoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.

Annotations
@Override