Package io.netty.channel.kqueue
Class KQueueEventLoop
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- All Implemented Interfaces:
EventLoop,EventLoopGroup,EventExecutor,EventExecutorGroup,OrderedEventExecutor,java.lang.Iterable<EventExecutor>,java.util.concurrent.Executor,java.util.concurrent.ExecutorService,java.util.concurrent.ScheduledExecutorService
final class KQueueEventLoop extends SingleThreadEventLoop
EventLoopwhich uses kqueue under the covers. Only works on BSD!
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classKQueueEventLoop.KQueueRegistration-
Nested classes/interfaces inherited from class io.netty.channel.SingleThreadEventLoop
SingleThreadEventLoop.ChannelsReadOnlyIterator<T extends Channel>
-
Nested classes/interfaces inherited from class io.netty.util.concurrent.SingleThreadEventExecutor
SingleThreadEventExecutor.NonWakeupRunnable
-
Nested classes/interfaces inherited from class io.netty.util.concurrent.AbstractEventExecutor
AbstractEventExecutor.LazyRunnable
-
-
Field Summary
Fields Modifier and Type Field Description private booleanallowGrowingprivate java.util.Queue<KQueueEventLoop.KQueueRegistration>cancelledRegistrationsprivate KQueueEventArraychangeListprivate KQueueEventArrayeventListprivate intioRatioprivate IovArrayiovArrayprivate static intKQUEUE_MAX_TIMEOUT_SECONDSprivate static intKQUEUE_WAKE_UP_IDENTprivate FileDescriptorkqueueFdprivate static InternalLoggerloggerprivate longnextIdprivate LongObjectMap<KQueueEventLoop.KQueueRegistration>registrationsprivate IntSupplierselectNowSupplierprivate SelectStrategyselectStrategyprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<KQueueEventLoop>WAKEN_UP_UPDATERprivate intwakenUp-
Fields inherited from class io.netty.channel.SingleThreadEventLoop
DEFAULT_MAX_PENDING_TASKS
-
-
Constructor Summary
Constructors Constructor Description KQueueEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) KQueueEventLoop.KQueueRegistrationadd(AbstractKQueueChannel ch)(package private) IovArraycleanArray()protected voidcleanup()Do nothing, sub-classes may overrideprivate voidcloseAll()private longgenerateNextId()intgetIoRatio()Returns the percentage of the desired amount of time spent for I/O in the event loop.private static voidhandleLoopException(java.lang.Throwable t)private intkqueueWait(boolean oldWakeup)private intkqueueWait(int timeoutSec, int timeoutNs)private intkqueueWaitNow()protected java.util.Queue<java.lang.Runnable>newTaskQueue(int maxPendingTasks)Create a newQueuewhich will holds the tasks to execute.private static java.util.Queue<java.lang.Runnable>newTaskQueue(EventLoopTaskQueueFactory queueFactory)private static java.util.Queue<java.lang.Runnable>newTaskQueue0(int maxPendingTasks)private voidprocessCancelledRegistrations()private voidprocessReady(int ready)intregisteredChannels()java.util.Iterator<Channel>registeredChannelsIterator()protected voidrun()Run the tasks in theSingleThreadEventExecutor.taskQueuevoidsetIoRatio(int ioRatio)Sets the percentage of the desired amount of time spent for I/O in the event loop.private voidwakeup()protected voidwakeup(boolean inEventLoop)-
Methods inherited from class io.netty.channel.SingleThreadEventLoop
afterRunningAllTasks, executeAfterEventLoopIteration, hasTasks, next, parent, pendingTasks, register, register, register
-
Methods inherited from class io.netty.util.concurrent.SingleThreadEventExecutor
addShutdownHook, addTask, awaitTermination, confirmShutdown, deadlineNanos, delayNanos, execute, inEventLoop, interruptThread, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isShuttingDown, isTerminated, lazyExecute, newTaskQueue, peekTask, pollTask, pollTaskFrom, reject, reject, removeShutdownHook, removeTask, runAllTasks, runAllTasks, runAllTasksFrom, runScheduledAndExecutorTasks, shutdown, shutdownGracefully, takeTask, terminationFuture, threadProperties, updateLastExecutionTime, wakesUpForTask
-
Methods inherited from class io.netty.util.concurrent.AbstractScheduledEventExecutor
afterScheduledTaskSubmitted, beforeScheduledTaskSubmitted, cancelScheduledTasks, deadlineToDelayNanos, getCurrentTimeNanos, hasScheduledTasks, initialNanoTime, nanoTime, nextScheduledTaskDeadlineNanos, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, validateScheduled
-
Methods inherited from class io.netty.util.concurrent.AbstractEventExecutor
inEventLoop, iterator, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, newTaskFor, newTaskFor, runTask, safeExecute, shutdownGracefully, shutdownNow, submit, submit, submit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.EventExecutor
inEventLoop, inEventLoop, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture
-
Methods inherited from interface io.netty.util.concurrent.EventExecutorGroup
isShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFuture
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
WAKEN_UP_UPDATER
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<KQueueEventLoop> 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
-
iovArray
private final IovArray iovArray
-
selectNowSupplier
private final IntSupplier selectNowSupplier
-
registrations
private final LongObjectMap<KQueueEventLoop.KQueueRegistration> registrations
-
cancelledRegistrations
private final java.util.Queue<KQueueEventLoop.KQueueRegistration> cancelledRegistrations
-
nextId
private long nextId
-
wakenUp
private volatile int wakenUp
-
ioRatio
private volatile int ioRatio
-
-
Constructor Detail
-
KQueueEventLoop
KQueueEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)
-
-
Method Detail
-
newTaskQueue
private static java.util.Queue<java.lang.Runnable> newTaskQueue(EventLoopTaskQueueFactory queueFactory)
-
generateNextId
private long generateNextId()
-
processCancelledRegistrations
private void processCancelledRegistrations()
-
add
KQueueEventLoop.KQueueRegistration add(AbstractKQueueChannel ch)
-
cleanArray
IovArray cleanArray()
-
wakeup
protected void wakeup(boolean inEventLoop)
- Overrides:
wakeupin classSingleThreadEventExecutor
-
wakeup
private void wakeup()
-
kqueueWait
private int kqueueWait(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 void processReady(int ready)
-
run
protected void run()
Description copied from class:SingleThreadEventExecutorRun the tasks in theSingleThreadEventExecutor.taskQueue- Specified by:
runin classSingleThreadEventExecutor
-
newTaskQueue
protected java.util.Queue<java.lang.Runnable> newTaskQueue(int maxPendingTasks)
Description copied from class:SingleThreadEventExecutorCreate a newQueuewhich will holds the tasks to execute. This default implementation will return aLinkedBlockingQueuebut if your sub-class ofSingleThreadEventExecutorwill not do any blocking calls on the thisQueueit may make sense to@Overridethis and return some more performant implementation that does not support blocking operations at all.- Overrides:
newTaskQueuein classSingleThreadEventExecutor
-
newTaskQueue0
private static java.util.Queue<java.lang.Runnable> newTaskQueue0(int maxPendingTasks)
-
getIoRatio
public int getIoRatio()
Returns the percentage of the desired amount of time spent for I/O in the event loop.
-
setIoRatio
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 is50, which means the event loop will try to spend the same amount of time for I/O as for non-I/O tasks.
-
registeredChannels
public int registeredChannels()
Description copied from class:SingleThreadEventLoopReturns the number ofChannels registered with thisEventLoopor-1if operation is not supported. The returned value is not guaranteed to be exact accurate and should be viewed as a best effort.- Overrides:
registeredChannelsin classSingleThreadEventLoop
-
registeredChannelsIterator
public java.util.Iterator<Channel> registeredChannelsIterator()
- Overrides:
registeredChannelsIteratorin classSingleThreadEventLoop- Returns:
- read-only iterator of active
Channels registered with thisEventLoop. 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.
-
cleanup
protected void cleanup()
Description copied from class:SingleThreadEventExecutorDo nothing, sub-classes may override- Overrides:
cleanupin classSingleThreadEventExecutor
-
closeAll
private void closeAll()
-
handleLoopException
private static void handleLoopException(java.lang.Throwable t)
-
-