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,io.netty.util.concurrent.EventExecutor,io.netty.util.concurrent.EventExecutorGroup,io.netty.util.concurrent.OrderedEventExecutor,io.netty.util.concurrent.ThreadAwareExecutor,Iterable<io.netty.util.concurrent.EventExecutor>,Executor,ExecutorService,ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventLoop,SingleThreadIoEventLoop,ThreadPerChannelEventLoop
public abstract class SingleThreadEventLoop extends io.netty.util.concurrent.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>
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_MAX_PENDING_TASKS
-
Constructor Summary
Constructors Modifier Constructor Description protectedSingleThreadEventLoop(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, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, int maxPendingTasks, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, io.netty.util.concurrent.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, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)protectedSingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidafterRunningAllTasks()voidexecuteAfterEventLoopIteration(Runnable task)Adds a task to be run once at the end of next (or current)eventloopiteration.protected booleanhasTasks()EventLoopnext()Return the nextEventLoopto useEventLoopGroupparent()intpendingTasks()ChannelFutureregister(Channel channel)ChannelFutureregister(ChannelPromise promise)ChannelFutureregister(Channel channel, ChannelPromise promise)Deprecated.intregisteredChannels()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, 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
-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, int maxPendingTasks, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, boolean supportSuspension, int maxPendingTasks, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
-
SingleThreadEventLoop
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, io.netty.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
-
-
Method Detail
-
parent
public EventLoopGroup parent()
-
next
public EventLoop next()
Description copied from interface:EventLoopGroupReturn the nextEventLoopto use- Specified by:
nextin interfaceio.netty.util.concurrent.EventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Overrides:
nextin classio.netty.util.concurrent.AbstractEventExecutor
-
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(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()
- Overrides:
afterRunningAllTasksin classio.netty.util.concurrent.SingleThreadEventExecutor
-
hasTasks
protected boolean hasTasks()
- Overrides:
hasTasksin classio.netty.util.concurrent.SingleThreadEventExecutor
-
pendingTasks
public int pendingTasks()
- Overrides:
pendingTasksin classio.netty.util.concurrent.SingleThreadEventExecutor
-
registeredChannels
@UnstableApi public int registeredChannels()
-
registeredChannelsIterator
@UnstableApi public 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:
UnsupportedOperationException- if operation is not supported by implementation.
-
-