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 forEventLoops that execute all its submitted tasks in a single thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSingleThreadEventLoop.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 intDEFAULT_MAX_PENDING_TASKS
-
Constructor Summary
Constructors Modifier Constructor Description protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp)protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension)protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(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)protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(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)protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp)protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension)protectedSingleThreadEventLoop(EventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(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 voidafterRunningAllTasks()Invoked before returning fromSingleThreadEventExecutor.runAllTasks()andSingleThreadEventExecutor.runAllTasks(long).voidexecuteAfterEventLoopIteration(java.lang.Runnable task)Adds a task to be run once at the end of next (or current)eventloopiteration.protected booleanhasTasks()EventLoopnext()Returns one of theEventExecutors managed by thisEventExecutorGroup.EventLoopGroupparent()Return theEventExecutorGroupwhich is the parent of thisEventExecutor,intpendingTasks()Return the number of tasks that are pending for processing.ChannelFutureregister(Channel channel)ChannelFutureregister(ChannelPromise promise)ChannelFutureregister(Channel channel, ChannelPromise promise)Deprecated.intregisteredChannels()java.util.Iterator<Channel>registeredChannelsIterator()-
Methods inherited from class io.netty.util.concurrent.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, 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, ticker, 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, ticker
-
-
-
-
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:EventExecutorReturn theEventExecutorGroupwhich is the parent of thisEventExecutor,- Specified by:
parentin interfaceEventExecutor- Specified by:
parentin interfaceEventLoop- Overrides:
parentin classAbstractEventExecutor
-
next
public EventLoop next()
Description copied from interface:EventExecutorGroupReturns one of theEventExecutors managed by thisEventExecutorGroup.- Specified by:
nextin interfaceEventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Overrides:
nextin classAbstractEventExecutor
-
register
public ChannelFuture register(Channel channel)
Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoop. The returnedChannelFuturewill get notified once the registration was complete.- Specified by:
registerin interfaceEventLoopGroup
-
register
public ChannelFuture register(ChannelPromise promise)
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 public ChannelFuture register(Channel channel, ChannelPromise promise)
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
public final void executeAfterEventLoopIteration(java.lang.Runnable task)
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:
Collection.isEmpty()
-
pendingTasks
public int pendingTasks()
Description copied from class:SingleThreadEventExecutorReturn the number of tasks that are pending for processing.- Overrides:
pendingTasksin classSingleThreadEventExecutor
-
registeredChannels
@UnstableApi public int registeredChannels()
-
registeredChannelsIterator
@UnstableApi public java.util.Iterator<Channel> 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:
java.lang.UnsupportedOperationException- if operation is not supported by implementation.
-
-