Package io.netty.channel
Class SingleThreadEventLoop
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- io.netty.util.concurrent.AbstractEventExecutor
-
- io.netty.util.concurrent.AbstractScheduledEventExecutor
-
- io.netty.util.concurrent.SingleThreadEventExecutor
-
- io.netty.channel.SingleThreadEventLoop
-
- All Implemented Interfaces:
EventLoop
,EventLoopGroup
,EventExecutor
,EventExecutorGroup
,OrderedEventExecutor
,ThreadAwareExecutor
,java.lang.Iterable<EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventLoop
,SingleThreadIoEventLoop
,ThreadPerChannelEventLoop
public abstract class SingleThreadEventLoop extends SingleThreadEventExecutor implements EventLoop
Abstract base class forEventLoop
s that execute all its submitted tasks in a single thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
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
Fields Modifier and Type Field Description protected static int
DEFAULT_MAX_PENDING_TASKS
-
Constructor Summary
Constructors Modifier Constructor Description protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension, java.util.Queue<java.lang.Runnable> taskQueue, java.util.Queue<java.lang.Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, java.util.Queue<java.lang.Runnable> taskQueue, java.util.Queue<java.lang.Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
protected
SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
afterRunningAllTasks()
Invoked before returning fromSingleThreadEventExecutor.runAllTasks()
andSingleThreadEventExecutor.runAllTasks(long)
.void
executeAfterEventLoopIteration(java.lang.Runnable task)
Adds a task to be run once at the end of next (or current)eventloop
iteration.protected boolean
hasTasks()
EventLoop
next()
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.EventLoopGroup
parent()
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,int
pendingTasks()
Return the number of tasks that are pending for processing.ChannelFuture
register(Channel channel)
ChannelFuture
register(ChannelPromise promise)
ChannelFuture
register(Channel channel, ChannelPromise promise)
Deprecated.int
registeredChannels()
java.util.Iterator<Channel>
registeredChannelsIterator()
-
Methods inherited from class io.netty.util.concurrent.SingleThreadEventExecutor
addShutdownHook, addTask, awaitTermination, canSuspend, canSuspend, cleanup, confirmShutdown, deadlineNanos, delayNanos, execute, inEventLoop, interruptThread, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isShuttingDown, isSuspended, isTerminated, lazyExecute, newTaskQueue, newTaskQueue, peekTask, pollTask, pollTaskFrom, reject, reject, removeShutdownHook, removeTask, run, runAllTasks, runAllTasks, runAllTasksFrom, runScheduledAndExecutorTasks, shutdown, shutdownGracefully, takeTask, terminationFuture, threadProperties, trySuspend, updateLastExecutionTime, wakesUpForTask, wakeup
-
Methods inherited from class io.netty.util.concurrent.AbstractScheduledEventExecutor
afterScheduledTaskSubmitted, beforeScheduledTaskSubmitted, cancelScheduledTasks, deadlineToDelayNanos, delayNanos, fetchFromScheduledTaskQueue, getCurrentTimeNanos, hasScheduledTasks, initialNanoTime, nanoTime, nextScheduledTaskDeadlineNanos, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, validateScheduled
-
Methods inherited from class io.netty.util.concurrent.AbstractEventExecutor
iterator, 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, isExecutorThread, isSuspended, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, trySuspend
-
Methods inherited from interface io.netty.util.concurrent.EventExecutorGroup
isShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFuture
-
-
-
-
Constructor Detail
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, java.util.Queue<java.lang.Runnable> taskQueue, java.util.Queue<java.lang.Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension, java.util.Queue<java.lang.Runnable> taskQueue, java.util.Queue<java.lang.Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
-
-
Method Detail
-
parent
public EventLoopGroup 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
public EventLoop next()
Description copied from interface:EventExecutorGroup
Returns one of theEventExecutor
s managed by thisEventExecutorGroup
.- Specified by:
next
in interfaceEventExecutorGroup
- Specified by:
next
in interfaceEventLoopGroup
- Overrides:
next
in classAbstractEventExecutor
-
register
public ChannelFuture register(Channel channel)
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
public ChannelFuture register(ChannelPromise promise)
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 public ChannelFuture register(Channel channel, ChannelPromise promise)
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
public final void executeAfterEventLoopIteration(java.lang.Runnable task)
Adds a task to be run once at the end of next (or current)eventloop
iteration.- Parameters:
task
- to be added.
-
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:
Collection.isEmpty()
-
pendingTasks
public int pendingTasks()
Description copied from class:SingleThreadEventExecutor
Return the number of tasks that are pending for processing.- Overrides:
pendingTasks
in classSingleThreadEventExecutor
-
registeredChannels
@UnstableApi public int registeredChannels()
-
registeredChannelsIterator
@UnstableApi public java.util.Iterator<Channel> 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:
java.lang.UnsupportedOperationException
- if operation is not supported by implementation.
-
-