Class SingleThreadEventLoop
- All Implemented Interfaces:
EventLoop, EventLoopGroup, EventExecutor, EventExecutorGroup, OrderedEventExecutor, ThreadAwareExecutor, Iterable<EventExecutor>, Executor, ExecutorService, ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventLoop, SingleThreadIoEventLoop, ThreadPerChannelEventLoop
Abstract base class for
EventLoops that execute all its submitted tasks in a single thread.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classNested classes/interfaces inherited from class SingleThreadEventExecutor
SingleThreadEventExecutor.NonWakeupRunnableNested classes/interfaces inherited from class AbstractEventExecutor
AbstractEventExecutor.LazyRunnable -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp) protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension) protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler) protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler) protectedSingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp) protectedSingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension) protectedSingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) protectedSingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidInvoked before returning fromSingleThreadEventExecutor.runAllTasks()andSingleThreadEventExecutor.runAllTasks(long).final voidAdds a task to be run once at the end of next (or current)eventloopiteration.protected booleanhasTasks()next()Returns one of theEventExecutors managed by thisEventExecutorGroup.parent()Return theEventExecutorGroupwhich is the parent of thisEventExecutor,intReturn the number of tasks that are pending for processing.register(ChannelPromise promise) register(Channel channel, ChannelPromise promise) Deprecated.intMethods inherited from class SingleThreadEventExecutor
addShutdownHook, addTask, awaitTermination, canSuspend, canSuspend, cleanup, confirmShutdown, deadlineNanos, delayNanos, execute, getAndIncrementBusyCycles, getAndIncrementIdleCycles, getAndResetAccumulatedActiveTimeNanos, getLastActivityTimeNanos, getNumOfRegisteredChannels, inEventLoop, interruptThread, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isShuttingDown, isSuspended, isSuspensionSupported, isTerminated, lazyExecute, newTaskQueue, newTaskQueue, peekTask, pollTask, pollTaskFrom, reject, reject, removeShutdownHook, removeTask, reportActiveIoTime, resetBusyCycles, resetIdleCycles, run, runAllTasks, runAllTasks, runAllTasksFrom, runScheduledAndExecutorTasks, shutdown, shutdownGracefully, takeTask, terminationFuture, threadProperties, trySuspend, updateLastExecutionTime, wakesUpForTask, wakeupMethods inherited from class AbstractScheduledEventExecutor
afterScheduledTaskSubmitted, beforeScheduledTaskSubmitted, cancelScheduledTasks, deadlineToDelayNanos, delayNanos, fetchFromScheduledTaskQueue, getCurrentTimeNanos, hasScheduledTasks, initialNanoTime, nanoTime, nextScheduledTaskDeadlineNanos, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, ticker, validateScheduledMethods inherited from class AbstractEventExecutor
iterator, newTaskFor, newTaskFor, runTask, safeExecute, shutdownGracefully, shutdownNow, submit, submit, submitMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventExecutor
inEventLoop, inEventLoop, isExecutorThread, isSuspended, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, trySuspendMethods inherited from interface EventExecutorGroup
isShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFuture, tickerMethods inherited from interface ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminatedMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_MAX_PENDING_TASKS
protected static final int DEFAULT_MAX_PENDING_TASKS
-
-
Constructor Details
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension) -
SingleThreadEventLoop
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler) -
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
-
-
Method Details
-
parent
Description copied from interface:EventExecutorReturn theEventExecutorGroupwhich is the parent of thisEventExecutor,- Specified by:
parentin interfaceEventExecutor- Specified by:
parentin interfaceEventLoop- Overrides:
parentin classAbstractEventExecutor
-
next
Description copied from interface:EventExecutorGroupReturns one of theEventExecutors managed by thisEventExecutorGroup.- Specified by:
nextin interfaceEventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Overrides:
nextin classAbstractEventExecutor
-
register
Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoop. The returnedChannelFuturewill get notified once the registration was complete.- Specified by:
registerin interfaceEventLoopGroup
-
register
Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoopusing aChannelFuture. The passedChannelFuturewill get notified once the registration was complete and also will get returned.- Specified by:
registerin interfaceEventLoopGroup
-
register
Deprecated.Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoop. The passedChannelFuturewill get notified once the registration was complete and also will get returned.- Specified by:
registerin interfaceEventLoopGroup
-
executeAfterEventLoopIteration
Adds a task to be run once at the end of next (or current)eventloopiteration.- Parameters:
task- to be added.
-
afterRunningAllTasks
protected void afterRunningAllTasks()Description copied from class:SingleThreadEventExecutorInvoked before returning fromSingleThreadEventExecutor.runAllTasks()andSingleThreadEventExecutor.runAllTasks(long).- Overrides:
afterRunningAllTasksin classSingleThreadEventExecutor
-
hasTasks
protected boolean hasTasks()- Overrides:
hasTasksin classSingleThreadEventExecutor- See Also:
-
pendingTasks
public int pendingTasks()Description copied from class:SingleThreadEventExecutorReturn the number of tasks that are pending for processing.- Overrides:
pendingTasksin classSingleThreadEventExecutor
-
registeredChannels
-
registeredChannelsIterator
- 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. - Throws:
UnsupportedOperationException- if operation is not supported by implementation.
-