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.Executor executor,
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) |
afterRunningAllTasks, executeAfterEventLoopIteration, hasTasks, next, parent, register, register, register, wakesUpForTaskaddShutdownHook, addTask, awaitTermination, confirmShutdown, delayNanos, execute, inEventLoop, interruptThread, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isShuttingDown, isTerminated, newTaskQueue, peekTask, pollTask, pollTaskFrom, reject, reject, removeShutdownHook, removeTask, runAllTasks, runAllTasks, runAllTasksFrom, shutdown, shutdownGracefully, takeTask, terminationFuture, threadProperties, updateLastExecutionTimecancelScheduledTasks, hasScheduledTasks, nanoTime, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelayinEventLoop, iterator, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, newTaskFor, newTaskFor, safeExecute, shutdownGracefully, shutdownNow, submit, submit, submitclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinEventLoop, inEventLoop, newFailedFuture, newProgressivePromise, newPromise, newSucceededFutureisShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFutureprivate 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.Executor executor, int maxEvents, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler)
IovArray cleanArray()
protected void wakeup(boolean inEventLoop)
wakeup in class SingleThreadEventExecutorvoid add(AbstractEpollChannel ch) throws java.io.IOException
EventLoop.java.io.IOExceptionvoid modify(AbstractEpollChannel ch) throws java.io.IOException
java.io.IOExceptionvoid remove(AbstractEpollChannel ch) throws java.io.IOException
EventLoop.java.io.IOExceptionprotected java.util.Queue<java.lang.Runnable> newTaskQueue(int maxPendingTasks)
SingleThreadEventExecutorQueue 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 SingleThreadEventExecutorpublic int pendingTasks()
SingleThreadEventExecutorpendingTasks in class SingleThreadEventLooppublic 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.IOExceptionprotected void run()
run in class SingleThreadEventExecutorprivate static void handleLoopException(java.lang.Throwable t)
private void closeAll()
private void processReady(EpollEventArray events, int ready)
protected void cleanup()
SingleThreadEventExecutorcleanup in class SingleThreadEventExecutor