Package io.netty.channel.kqueue
Class KQueueEventLoop
- All Implemented Interfaces:
EventLoop
,EventLoopGroup
,EventExecutor
,EventExecutorGroup
,OrderedEventExecutor
,AutoCloseable
,Iterable<EventExecutor>
,Executor
,ExecutorService
,ScheduledExecutorService
EventLoop
which uses kqueue under the covers. Only works on BSD!-
Nested Class Summary
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
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final KQueueEventArray
private final IntObjectMap
<AbstractKQueueChannel> private final KQueueEventArray
private int
private final IovArray
private static final int
private static final int
private final FileDescriptor
private static final InternalLogger
private final IntSupplier
private final SelectStrategy
private static final AtomicIntegerFieldUpdater
<KQueueEventLoop> private int
Fields inherited from class io.netty.channel.SingleThreadEventLoop
DEFAULT_MAX_PENDING_TASKS
-
Constructor Summary
ConstructorsConstructorDescriptionKQueueEventLoop
(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory) -
Method Summary
Modifier and TypeMethodDescription(package private) void
(package private) IovArray
protected void
cleanup()
Do nothing, sub-classes may overrideprivate void
closeAll()
(package private) void
evSet
(AbstractKQueueChannel ch, short filter, short flags, int fflags) int
Returns the percentage of the desired amount of time spent for I/O in the event loop.private static void
private int
kqueueWait
(boolean oldWakeup) private int
kqueueWait
(int timeoutSec, int timeoutNs) private int
newTaskQueue
(int maxPendingTasks) Create a newQueue
which will holds the tasks to execute.newTaskQueue
(EventLoopTaskQueueFactory queueFactory) newTaskQueue0
(int maxPendingTasks) private void
processReady
(int ready) int
(package private) void
protected void
run()
Run the tasks in theSingleThreadEventExecutor.taskQueue
void
setIoRatio
(int ioRatio) Sets the percentage of the desired amount of time spent for I/O in the event loop.private void
wakeup()
protected void
wakeup
(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
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, close, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
-
WAKEN_UP_UPDATER
-
KQUEUE_WAKE_UP_IDENT
private static final int KQUEUE_WAKE_UP_IDENT- See Also:
-
KQUEUE_MAX_TIMEOUT_SECONDS
private static final int KQUEUE_MAX_TIMEOUT_SECONDS- See Also:
-
allowGrowing
private final boolean allowGrowing -
kqueueFd
-
changeList
-
eventList
-
selectStrategy
-
iovArray
-
selectNowSupplier
-
channels
-
wakenUp
private volatile int wakenUp -
ioRatio
private volatile int ioRatio
-
-
Constructor Details
-
KQueueEventLoop
KQueueEventLoop(EventLoopGroup parent, Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)
-
-
Method Details
-
newTaskQueue
-
add
-
evSet
-
remove
- Throws:
Exception
-
cleanArray
IovArray cleanArray() -
wakeup
protected void wakeup(boolean inEventLoop) - Overrides:
wakeup
in classSingleThreadEventExecutor
-
wakeup
private void wakeup() -
kqueueWait
- Throws:
IOException
-
kqueueWaitNow
- Throws:
IOException
-
kqueueWait
- Throws:
IOException
-
processReady
private void processReady(int ready) -
run
protected void run()Description copied from class:SingleThreadEventExecutor
Run the tasks in theSingleThreadEventExecutor.taskQueue
- Specified by:
run
in classSingleThreadEventExecutor
-
newTaskQueue
Description copied from class:SingleThreadEventExecutor
Create a newQueue
which will holds the tasks to execute. This default implementation will return aLinkedBlockingQueue
but if your sub-class ofSingleThreadEventExecutor
will not do any blocking calls on the thisQueue
it may make sense to@Override
this and return some more performant implementation that does not support blocking operations at all.- Overrides:
newTaskQueue
in classSingleThreadEventExecutor
-
newTaskQueue0
-
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:SingleThreadEventLoop
Returns the number ofChannel
s registered with thisEventLoop
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.- Overrides:
registeredChannels
in classSingleThreadEventLoop
-
registeredChannelsIterator
- Overrides:
registeredChannelsIterator
in classSingleThreadEventLoop
- Returns:
- read-only iterator of active
Channel
s 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:SingleThreadEventExecutor
Do nothing, sub-classes may override- Overrides:
cleanup
in classSingleThreadEventExecutor
-
closeAll
private void closeAll() -
handleLoopException
-