Package io.netty.channel.kqueue
Class KQueueIoHandler
- java.lang.Object
-
- io.netty.channel.kqueue.KQueueIoHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classKQueueIoHandler.DefaultKqueueIoRegistration
-
Field Summary
Fields Modifier and Type Field Description private booleanallowGrowingprivate java.util.Queue<KQueueIoHandler.DefaultKqueueIoRegistration>cancelledRegistrationsprivate KQueueEventArraychangeListprivate KQueueEventArrayeventListprivate ThreadAwareExecutorexecutorprivate static intKQUEUE_MAX_TIMEOUT_SECONDSprivate static intKQUEUE_WAKE_UP_IDENTprivate FileDescriptorkqueueFdprivate static InternalLoggerloggerprivate NativeArraysnativeArraysprivate longnextIdprivate intnumChannelsprivate LongObjectMap<KQueueIoHandler.DefaultKqueueIoRegistration>registrationsprivate IntSupplierselectNowSupplierprivate SelectStrategyselectStrategyprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<KQueueIoHandler>WAKEN_UP_UPDATERprivate intwakenUp
-
Constructor Summary
Constructors Modifier Constructor Description privateKQueueIoHandler(ThreadAwareExecutor executor, int maxEvents, SelectStrategy strategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static KQueueIoHandlecast(IoHandle handle)private static KQueueIoOpscast(IoOps ops)voiddestroy()Destroy theIoHandlerand free all its resources.private longgenerateNextId()private static voidhandleLoopException(java.lang.Throwable t)booleanisCompatible(java.lang.Class<? extends IoHandle> handleType)Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.private intkqueueWait(int timeoutSec, int timeoutNs)private intkqueueWait(IoHandlerContext context, boolean oldWakeup)private intkqueueWaitNow()static IoHandlerFactorynewFactory()Returns a newIoHandlerFactorythat createsKQueueIoHandlerinstances.static IoHandlerFactorynewFactory(int maxEvents, SelectStrategyFactory selectStrategyFactory)Returns a newIoHandlerFactorythat createsKQueueIoHandlerinstances.(package private) intnumRegisteredChannels()voidprepareToDestroy()Prepare to destroy thisIoHandler.private voidprocessCancelledRegistrations()private intprocessReady(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.private voidwakeup0()-
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
-
WAKEN_UP_UPDATER
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<KQueueIoHandler> WAKEN_UP_UPDATER
-
KQUEUE_WAKE_UP_IDENT
private static final int KQUEUE_WAKE_UP_IDENT
- See Also:
- Constant Field Values
-
KQUEUE_MAX_TIMEOUT_SECONDS
private static final int KQUEUE_MAX_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
allowGrowing
private final boolean allowGrowing
-
kqueueFd
private final FileDescriptor kqueueFd
-
changeList
private final KQueueEventArray changeList
-
eventList
private final KQueueEventArray eventList
-
selectStrategy
private final SelectStrategy selectStrategy
-
nativeArrays
private final NativeArrays nativeArrays
-
selectNowSupplier
private final IntSupplier selectNowSupplier
-
executor
private final ThreadAwareExecutor executor
-
cancelledRegistrations
private final java.util.Queue<KQueueIoHandler.DefaultKqueueIoRegistration> cancelledRegistrations
-
registrations
private final LongObjectMap<KQueueIoHandler.DefaultKqueueIoRegistration> registrations
-
numChannels
private int numChannels
-
nextId
private long nextId
-
wakenUp
private volatile int wakenUp
-
-
Constructor Detail
-
KQueueIoHandler
private KQueueIoHandler(ThreadAwareExecutor executor, int maxEvents, SelectStrategy strategy)
-
-
Method Detail
-
generateNextId
private long generateNextId()
-
newFactory
public static IoHandlerFactory newFactory()
Returns a newIoHandlerFactorythat createsKQueueIoHandlerinstances.
-
newFactory
public static IoHandlerFactory newFactory(int maxEvents, SelectStrategyFactory selectStrategyFactory)
Returns a newIoHandlerFactorythat createsKQueueIoHandlerinstances.
-
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.
-
wakeup0
private void wakeup0()
-
kqueueWait
private int kqueueWait(IoHandlerContext context, boolean oldWakeup) throws java.io.IOException
- Throws:
java.io.IOException
-
kqueueWaitNow
private int kqueueWaitNow() throws java.io.IOException- Throws:
java.io.IOException
-
kqueueWait
private int kqueueWait(int timeoutSec, int timeoutNs) throws java.io.IOException- Throws:
java.io.IOException
-
processReady
private int processReady(int ready)
-
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.
-
processCancelledRegistrations
private void processCancelledRegistrations()
-
numRegisteredChannels
int numRegisteredChannels()
-
registeredChannelsList
java.util.List<Channel> registeredChannelsList()
-
handleLoopException
private static void handleLoopException(java.lang.Throwable t)
-
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)
Description copied from interface:IoHandlerRegister aIoHandlefor IO.
-
cast
private static KQueueIoHandle cast(IoHandle handle)
-
cast
private static KQueueIoOps cast(IoOps ops)
-
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.
-
-