Package io.netty.channel
Class SingleThreadEventLoop
- All Implemented Interfaces:
EventLoop
,EventLoopGroup
,EventExecutor
,EventExecutorGroup
,OrderedEventExecutor
,AutoCloseable
,Iterable<EventExecutor>
,Executor
,ExecutorService
,ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventLoop
,EpollEventLoop
,KQueueEventLoop
,NioEventLoop
,ThreadPerChannelEventLoop
Abstract base class for
EventLoop
s that execute all its submitted tasks in a single thread.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final class
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 TypeFieldDescriptionprotected static final int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SingleThreadEventLoop
(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp) protected
SingleThreadEventLoop
(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) protected
SingleThreadEventLoop
(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler) protected
SingleThreadEventLoop
(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp) protected
SingleThreadEventLoop
(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Invoked before returning fromSingleThreadEventExecutor.runAllTasks()
andSingleThreadEventExecutor.runAllTasks(long)
.final void
Adds a task to be run once at the end of next (or current)eventloop
iteration.protected boolean
hasTasks()
next()
Returns a reference to itself.parent()
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,int
Return the number of tasks that are pending for processing.register
(ChannelPromise promise) register
(Channel channel, ChannelPromise promise) Deprecated.int
(package private) final boolean
Removes a task that was added previously viaexecuteAfterEventLoopIteration(Runnable)
.Methods inherited from class io.netty.util.concurrent.SingleThreadEventExecutor
addShutdownHook, addTask, awaitTermination, cleanup, confirmShutdown, deadlineNanos, delayNanos, execute, inEventLoop, interruptThread, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isShuttingDown, isTerminated, lazyExecute, newTaskQueue, newTaskQueue, peekTask, pollTask, pollTaskFrom, reject, reject, removeShutdownHook, removeTask, run, runAllTasks, runAllTasks, runAllTasksFrom, runScheduledAndExecutorTasks, shutdown, shutdownGracefully, takeTask, terminationFuture, threadProperties, updateLastExecutionTime, wakesUpForTask, wakeup
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
-
DEFAULT_MAX_PENDING_TASKS
protected static final int DEFAULT_MAX_PENDING_TASKS -
tailTasks
-
-
Constructor Details
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp) -
SingleThreadEventLoop
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, 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, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
-
-
Method Details
-
parent
Description copied from interface:EventExecutor
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,- Specified by:
parent
in interfaceEventExecutor
- Specified by:
parent
in interfaceEventLoop
- Overrides:
parent
in classAbstractEventExecutor
-
next
Description copied from interface:EventExecutor
Returns a reference to itself.- Specified by:
next
in interfaceEventExecutor
- Specified by:
next
in interfaceEventExecutorGroup
- Specified by:
next
in interfaceEventLoopGroup
- Overrides:
next
in classAbstractEventExecutor
-
register
Description copied from interface:EventLoopGroup
Register aChannel
with thisEventLoop
. The returnedChannelFuture
will get notified once the registration was complete.- Specified by:
register
in interfaceEventLoopGroup
-
register
Description copied from interface:EventLoopGroup
Register aChannel
with thisEventLoop
using aChannelFuture
. The passedChannelFuture
will get notified once the registration was complete and also will get returned.- Specified by:
register
in interfaceEventLoopGroup
-
register
Deprecated.Description copied from interface:EventLoopGroup
Register aChannel
with thisEventLoop
. The passedChannelFuture
will get notified once the registration was complete and also will get returned.- Specified by:
register
in interfaceEventLoopGroup
-
executeAfterEventLoopIteration
Adds a task to be run once at the end of next (or current)eventloop
iteration.- Parameters:
task
- to be added.
-
removeAfterEventLoopIterationTask
Removes a task that was added previously viaexecuteAfterEventLoopIteration(Runnable)
.- Parameters:
task
- to be removed.- Returns:
true
if the task was removed as a result of this call.
-
afterRunningAllTasks
protected void afterRunningAllTasks()Description copied from class:SingleThreadEventExecutor
Invoked before returning fromSingleThreadEventExecutor.runAllTasks()
andSingleThreadEventExecutor.runAllTasks(long)
.- Overrides:
afterRunningAllTasks
in classSingleThreadEventExecutor
-
hasTasks
protected boolean hasTasks()- Overrides:
hasTasks
in classSingleThreadEventExecutor
- See Also:
-
pendingTasks
public int pendingTasks()Description copied from class:SingleThreadEventExecutor
Return the number of tasks that are pending for processing.- Overrides:
pendingTasks
in classSingleThreadEventExecutor
-
registeredChannels
-
registeredChannelsIterator
- 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. - Throws:
UnsupportedOperationException
- if operation is not supported by implementation.
-