Package io.netty.channel.epoll
Class EpollIoHandler
- java.lang.Object
-
- io.netty.channel.epoll.EpollIoHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classEpollIoHandler.DefaultEpollIoRegistrationprivate static classEpollIoHandler.RegistrationState
-
Field Summary
Fields Modifier and Type Field Description private booleanallowGrowingprivate static longAWAKEprivate static longEPOLL_WAIT_MILLIS_THRESHOLDprivate FileDescriptorepollFdprivate FileDescriptoreventFdprivate EpollEventArrayeventsprivate ThreadAwareExecutorexecutorprivate static InternalLoggerloggerprivate static longMAX_SCHEDULED_TIMERFD_NSprivate NativeArraysnativeArraysprivate java.util.concurrent.atomic.AtomicLongnextWakeupNanosprivate static longNONEprivate intnumChannelsprivate booleanpendingWakeupprivate longprevDeadlineNanosprivate IntObjectMap<EpollIoHandler.DefaultEpollIoRegistration>registrationsprivate IntSupplierselectNowSupplierprivate SelectStrategyselectStrategyprivate FileDescriptortimerFd
-
Constructor Summary
Constructors Constructor Description EpollIoHandler(ThreadAwareExecutor executor, int maxEvents, SelectStrategy strategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static EpollIoHandlecast(IoHandle handle)private static EpollIoOpscast(IoOps ops)private static voidcloseFileDescriptor(FileDescriptor fd)voidcloseFileDescriptors()This method is intended for use by process checkpoint/restore integration, such as OpenJDK CRaC.voiddestroy()Destroy theIoHandlerand free all its resources.private intepollBusyWait()private longepollWait(IoHandlerContext context, long deadlineNanos)private intepollWaitNoTimerChange()private intepollWaitNow()private intepollWaitTimeboxed()(package private) voidhandleLoopException(java.lang.Throwable t)Visible only for testing!booleanisCompatible(java.lang.Class<? extends IoHandle> handleType)Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.static IoHandlerFactorynewFactory()Returns a newIoHandlerFactorythat createsEpollIoHandlerinstances.static IoHandlerFactorynewFactory(int maxEvents, SelectStrategyFactory selectStrategyFactory)Returns a newIoHandlerFactorythat createsEpollIoHandlerinstances.(package private) intnumRegisteredChannels()voidopenFileDescriptors()This method is intended for use by a process checkpoint/restore integration, such as OpenJDK CRaC.voidprepareToDestroy()Prepare to destroy thisIoHandler.private intprocessReady(EpollEventArray events, int ready)IoRegistrationregister(IoHandle handle)Register aIoHandlefor IO.(package private) java.util.List<Channel>registeredChannelsList()intrun(IoHandlerContext context)Run the IO handled by thisIoHandler.voidwakeup()Wakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.IoHandler
initialize
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
EPOLL_WAIT_MILLIS_THRESHOLD
private static final long EPOLL_WAIT_MILLIS_THRESHOLD
-
prevDeadlineNanos
private long prevDeadlineNanos
-
epollFd
private FileDescriptor epollFd
-
eventFd
private FileDescriptor eventFd
-
timerFd
private FileDescriptor timerFd
-
registrations
private final IntObjectMap<EpollIoHandler.DefaultEpollIoRegistration> registrations
-
allowGrowing
private final boolean allowGrowing
-
events
private final EpollEventArray events
-
nativeArrays
private final NativeArrays nativeArrays
-
selectStrategy
private final SelectStrategy selectStrategy
-
selectNowSupplier
private final IntSupplier selectNowSupplier
-
executor
private final ThreadAwareExecutor executor
-
AWAKE
private static final long AWAKE
- See Also:
- Constant Field Values
-
NONE
private static final long NONE
- See Also:
- Constant Field Values
-
nextWakeupNanos
private final java.util.concurrent.atomic.AtomicLong nextWakeupNanos
-
pendingWakeup
private boolean pendingWakeup
-
numChannels
private int numChannels
-
MAX_SCHEDULED_TIMERFD_NS
private static final long MAX_SCHEDULED_TIMERFD_NS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EpollIoHandler
EpollIoHandler(ThreadAwareExecutor executor, int maxEvents, SelectStrategy strategy)
-
-
Method Detail
-
newFactory
public static IoHandlerFactory newFactory()
Returns a newIoHandlerFactorythat createsEpollIoHandlerinstances.
-
newFactory
public static IoHandlerFactory newFactory(int maxEvents, SelectStrategyFactory selectStrategyFactory)
Returns a newIoHandlerFactorythat createsEpollIoHandlerinstances.
-
cast
private static EpollIoHandle cast(IoHandle handle)
-
cast
private static EpollIoOps cast(IoOps ops)
-
openFileDescriptors
@UnstableApi public void openFileDescriptors()
This method is intended for use by a process checkpoint/restore integration, such as OpenJDK CRaC.
-
closeFileDescriptor
private static void closeFileDescriptor(FileDescriptor fd)
-
wakeup
public void wakeup()
Description copied from interface:IoHandlerWakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
-
prepareToDestroy
public void prepareToDestroy()
Description copied from interface:IoHandlerPrepare to destroy thisIoHandler. This method will be called beforeIoHandler.destroy()and may be called multiple times.- Specified by:
prepareToDestroyin interfaceIoHandler
-
destroy
public void destroy()
Description copied from interface:IoHandler
-
register
public IoRegistration register(IoHandle handle) throws java.lang.Exception
Description copied from interface:IoHandlerRegister aIoHandlefor IO.
-
isCompatible
public boolean isCompatible(java.lang.Class<? extends IoHandle> handleType)
Description copied from interface:IoHandlerReturnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.- Specified by:
isCompatiblein interfaceIoHandler- Parameters:
handleType- the type of theIoHandle.- Returns:
- if compatible of not.
-
numRegisteredChannels
int numRegisteredChannels()
-
registeredChannelsList
java.util.List<Channel> registeredChannelsList()
-
epollWait
private long epollWait(IoHandlerContext context, long deadlineNanos) throws java.io.IOException
- Throws:
java.io.IOException
-
epollWaitNoTimerChange
private int epollWaitNoTimerChange() throws java.io.IOException- Throws:
java.io.IOException
-
epollWaitNow
private int epollWaitNow() throws java.io.IOException- Throws:
java.io.IOException
-
epollBusyWait
private int epollBusyWait() throws java.io.IOException- Throws:
java.io.IOException
-
epollWaitTimeboxed
private int epollWaitTimeboxed() throws java.io.IOException- Throws:
java.io.IOException
-
run
public int run(IoHandlerContext context)
Description copied from interface:IoHandlerRun the IO handled by thisIoHandler. TheIoHandlerContextshould be used to ensure we not execute too long and so block the processing of other task that are scheduled on theThreadAwareExecutor. This is done by takingIoHandlerContext.delayNanos(long)orIoHandlerContext.deadlineNanos()into account.- Specified by:
runin interfaceIoHandler- Parameters:
context- theIoHandlerContext.- Returns:
- the number of
IoHandlefor which I/O was handled. Internal events such as wakeups and timer expirations must not be included in this count.
-
handleLoopException
void handleLoopException(java.lang.Throwable t)
Visible only for testing!
-
processReady
private int processReady(EpollEventArray events, int ready)
-
closeFileDescriptors
@UnstableApi 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.
-
-