final class EpollEventLoop extends SingleThreadEventLoop
EventLoop
which uses epoll under the covers. Only works on Linux!Modifier and Type | Field and Description |
---|---|
private boolean |
allowGrowing |
private IntObjectMap<AbstractEpollChannel> |
channels |
private FileDescriptor |
epollFd |
private FileDescriptor |
eventFd |
private EpollEventArray |
events |
private int |
ioRatio |
private IovArray |
iovArray |
private static InternalLogger |
logger |
private java.util.concurrent.Callable<java.lang.Integer> |
pendingTasksCallable |
private IntSupplier |
selectNowSupplier |
private SelectStrategy |
selectStrategy |
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<EpollEventLoop> |
WAKEN_UP_UPDATER |
private int |
wakenUp |
DEFAULT_MAX_PENDING_TASKS
Constructor and Description |
---|
EpollEventLoop(EventLoopGroup parent,
java.util.concurrent.ThreadFactory threadFactory,
int maxEvents,
SelectStrategy strategy,
RejectedExecutionHandler rejectedExecutionHandler) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(AbstractEpollChannel ch)
Register the given epoll with this
EventLoop . |
(package private) IovArray |
cleanArray()
|
protected void |
cleanup()
Do nothing, sub-classes may override
|
private void |
closeAll() |
private int |
epollWait(boolean oldWakenUp) |
int |
getIoRatio()
Returns the percentage of the desired amount of time spent for I/O in the event loop.
|
private static void |
handleLoopException(java.lang.Throwable t) |
(package private) void |
modify(AbstractEpollChannel ch)
The flags of the given epoll was modified so update the registration
|
protected java.util.Queue<java.lang.Runnable> |
newTaskQueue(int maxPendingTasks)
Create a new
Queue which will holds the tasks to execute. |
int |
pendingTasks()
Return the number of tasks that are pending for processing.
|
private void |
processReady(EpollEventArray events,
int ready) |
(package private) void |
remove(AbstractEpollChannel ch)
Deregister the given epoll from this
EventLoop . |
protected void |
run() |
void |
setIoRatio(int ioRatio)
Sets the percentage of the desired amount of time spent for I/O in the event loop.
|
protected void |
wakeup(boolean inEventLoop) |
next, parent, register, register, wakesUpForTask
addShutdownHook, addTask, awaitTermination, confirmShutdown, delayNanos, execute, hasTasks, inEventLoop, interruptThread, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isShuttingDown, isTerminated, newTaskQueue, peekTask, pollTask, reject, removeShutdownHook, removeTask, runAllTasks, runAllTasks, shutdown, shutdownGracefully, takeTask, terminationFuture, threadProperties, updateLastExecutionTime
cancelScheduledTasks, hasScheduledTasks, nanoTime, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay
inEventLoop, iterator, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, newTaskFor, newTaskFor, shutdownGracefully, shutdownNow, submit, submit, submit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
inEventLoop, inEventLoop, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture
isShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFuture
private static final InternalLogger logger
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<EpollEventLoop> WAKEN_UP_UPDATER
private final FileDescriptor epollFd
private final FileDescriptor eventFd
private final IntObjectMap<AbstractEpollChannel> channels
private final boolean allowGrowing
private final EpollEventArray events
private final IovArray iovArray
private final SelectStrategy selectStrategy
private final IntSupplier selectNowSupplier
private final java.util.concurrent.Callable<java.lang.Integer> pendingTasksCallable
private volatile int wakenUp
private volatile int ioRatio
EpollEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler)
IovArray cleanArray()
protected void wakeup(boolean inEventLoop)
wakeup
in class SingleThreadEventExecutor
void add(AbstractEpollChannel ch) throws java.io.IOException
EventLoop
.java.io.IOException
void modify(AbstractEpollChannel ch) throws java.io.IOException
java.io.IOException
void remove(AbstractEpollChannel ch) throws java.io.IOException
EventLoop
.java.io.IOException
protected java.util.Queue<java.lang.Runnable> newTaskQueue(int maxPendingTasks)
SingleThreadEventExecutor
Queue
which will holds the tasks to execute. This default implementation will return a
LinkedBlockingQueue
but if your sub-class of SingleThreadEventExecutor
will not do any blocking
calls on the this Queue
it may make sense to @Override
this and return some more performant
implementation that does not support blocking operations at all.newTaskQueue
in class SingleThreadEventExecutor
public int pendingTasks()
SingleThreadEventExecutor
pendingTasks
in class SingleThreadEventExecutor
public int getIoRatio()
public void setIoRatio(int ioRatio)
50
, which means the event loop will try to spend the same amount of time for I/O as for non-I/O tasks.private int epollWait(boolean oldWakenUp) throws java.io.IOException
java.io.IOException
protected void run()
run
in class SingleThreadEventExecutor
private static void handleLoopException(java.lang.Throwable t)
private void closeAll()
private void processReady(EpollEventArray events, int ready)
protected void cleanup()
SingleThreadEventExecutor
cleanup
in class SingleThreadEventExecutor