Top Description Inners Fields Constructors Methods
io.netty.channel

public abstract Class SingleThreadEventLoop

extends SingleThreadEventExecutor
implements EventLoop
Class Inheritance
All Implemented Interfaces
io.netty.channel.EventLoop, io.netty.channel.EventLoopGroup, io.netty.util.concurrent.EventExecutorGroup, java.lang.Iterable, java.util.concurrent.ScheduledExecutorService, java.util.concurrent.ExecutorService, java.lang.AutoCloseable, java.util.concurrent.Executor, io.netty.util.concurrent.OrderedEventExecutor, io.netty.util.concurrent.EventExecutor
Known Direct Subclasses
io.netty.channel.ThreadPerChannelEventLoop, io.netty.channel.nio.NioEventLoop, io.netty.channel.DefaultEventLoop
Imports
io.netty.util.concurrent.RejectedExecutionHandler, .RejectedExecutionHandlers, .SingleThreadEventExecutor, io.netty.util.internal.ObjectUtil, .SystemPropertyUtil, .UnstableApi, java.util.Iterator, .NoSuchElementException, .Queue, java.util.concurrent.Executor, .ThreadFactory

Abstract base class for EventLoops that execute all its submitted tasks in a single thread.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
protected static final int
private final Queue<Runnable>

Constructor Summary

AccessConstructor and Description
protected
SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp)

protected
SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp)

protected
SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)

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)

Method Summary

Modifier and TypeMethod and Description
protected void
public final void
executeAfterEventLoopIteration(Runnable
to be added.
task
)

Adds a task to be run once at the end of next (or current) eventloop iteration.

protected boolean
public EventLoop
public EventLoopGroup
public int
pendingTasks()

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.pendingTasks.

Return the number of tasks that are pending for processing.
public ChannelFuture
public ChannelFuture
register(final ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Register a Channel with this EventLoop using a ChannelFuture.
public ChannelFuture
register(final Channel channel, final ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Deprecated
Register a Channel with this EventLoop.
public int
registeredChannels()

Returns the number of Channels registered with this EventLoop or -1 if operation is not supported.

public Iterator<Channel>

Returns:

read-only iterator of active Channels registered with this EventLoop. 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.
registeredChannelsIterator
()

pack-priv final boolean

Returns:

true if the task was removed as a result of this call.
removeAfterEventLoopIterationTask
(Runnable
to be removed.
task
)

Removes a task that was added previously via executeAfterEventLoopIteration(Runnable).

Inherited from io.netty.util.concurrent.SingleThreadEventExecutor:
addShutdownHookaddTaskawaitTerminationcleanupconfirmShutdowndeadlineNanosdelayNanosexecuteinEventLoopinterruptThreadinvokeAllinvokeAllinvokeAnyinvokeAnyisShutdownisShuttingDownisTerminatedlazyExecutenewTaskQueuenewTaskQueuepeekTaskpollTaskpollTaskFromrejectrejectremoveShutdownHookremoveTaskrunrunAllTasksrunAllTasksrunAllTasksFromrunScheduledAndExecutorTasksshutdownshutdownGracefullytakeTaskterminationFuturethreadPropertiesupdateLastExecutionTimewakesUpForTaskwakeup

Field Detail

DEFAULT_MAX_PENDING_TASKSback to summary
protected static final int DEFAULT_MAX_PENDING_TASKS
tailTasksback to summary
private final Queue<Runnable> tailTasks

Constructor Detail

SingleThreadEventLoopback to summary
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp)
SingleThreadEventLoopback to summary
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp)
SingleThreadEventLoopback to summary
protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
SingleThreadEventLoopback to summary
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler)
SingleThreadEventLoopback to summary
protected SingleThreadEventLoop(EventLoopGroup parent, Executor executor, boolean addTaskWakesUp, Queue<Runnable> taskQueue, Queue<Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)

Method Detail

afterRunningAllTasksback to summary
protected void afterRunningAllTasks()

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.afterRunningAllTasks.

Doc from io.netty.util.concurrent.SingleThreadEventExecutor.afterRunningAllTasks.

Invoked before returning from runAllTasks() and runAllTasks(long).

Annotations
@Override
executeAfterEventLoopIterationback to summary
public final void executeAfterEventLoopIteration(Runnable task)

Adds a task to be run once at the end of next (or current) eventloop iteration.

Parameters
task:Runnable

to be added.

Annotations
@UnstableApi
hasTasksback to summary
protected boolean hasTasks()

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.hasTasks.

Annotations
@Override
nextback to summary
public EventLoop next()

Overrides io.netty.util.concurrent.AbstractEventExecutor.next.

Implements io.netty.util.concurrent.EventExecutor.next, io.netty.channel.EventLoopGroup.next.

Doc from io.netty.channel.EventLoopGroup.next.

Return the next EventLoop to use

Annotations
@Override
parentback to summary
public EventLoopGroup parent()

Overrides io.netty.util.concurrent.AbstractEventExecutor.parent.

Implements io.netty.channel.EventLoop.parent, io.netty.util.concurrent.EventExecutor.parent.

Doc from io.netty.util.concurrent.EventExecutor.parent.

Return the EventExecutorGroup which is the parent of this EventExecutor,

Annotations
@Override
pendingTasksback to summary
public int pendingTasks()

Overrides io.netty.util.concurrent.SingleThreadEventExecutor.pendingTasks.

Doc from io.netty.util.concurrent.SingleThreadEventExecutor.pendingTasks.

Return the number of tasks that are pending for processing.

Annotations
@Override
registerback to summary
public ChannelFuture register(Channel channel)

Implements io.netty.channel.EventLoopGroup.register.

Doc from io.netty.channel.EventLoopGroup.register.

Register a Channel with this EventLoop. The returned ChannelFuture will get notified once the registration was complete.

Annotations
@Override
registerback to summary
public ChannelFuture register(final ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Doc from io.netty.channel.EventLoopGroup.register.

Register a Channel with this EventLoop using a ChannelFuture. The passed ChannelFuture will get notified once the registration was complete and also will get returned.

Annotations
@Override
registerback to summary
public ChannelFuture register(final Channel channel, final ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Doc from io.netty.channel.EventLoopGroup.register.

Deprecated

Register a Channel with this EventLoop. The passed ChannelFuture will get notified once the registration was complete and also will get returned.

Annotations
@Deprecated
@Override
registeredChannelsback to summary
public int registeredChannels()

Returns the number of Channels registered with this EventLoop or -1 if operation is not supported. The returned value is not guaranteed to be exact accurate and should be viewed as a best effort.

Annotations
@UnstableApi
registeredChannelsIteratorback to summary
public Iterator<Channel> registeredChannelsIterator()
Returns:Iterator<Channel>

read-only iterator of active Channels registered with this EventLoop. 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.

Annotations
@UnstableApi
Exceptions
UnsupportedOperationException:
if operation is not supported by implementation.
removeAfterEventLoopIterationTaskback to summary
pack-priv final boolean removeAfterEventLoopIterationTask(Runnable task)

Removes a task that was added previously via executeAfterEventLoopIteration(Runnable).

Parameters
task:Runnable

to be removed.

Returns:boolean

true if the task was removed as a result of this call.

Annotations
@UnstableApi
io.netty.channel back to summary

protected final Class SingleThreadEventLoop.ChannelsReadOnlyIterator<T extends Channel>

extends Object
implements Iterator<Channel>
Class Inheritance
  • java.lang.Object
  • io.netty.channel.SingleThreadEventLoop.ChannelsReadOnlyIterator
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final Iterator<T>
private static final Iterator<Object>

Constructor Summary

AccessConstructor and Description
public
ChannelsReadOnlyIterator(Iterable<T> channelIterable)

Method Summary

Modifier and TypeMethod and Description
public static <T> Iterator<T>
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Channel
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelIteratorback to summary
private final Iterator<T> channelIterator
EMPTYback to summary
private static final Iterator<Object> EMPTY

Constructor Detail

ChannelsReadOnlyIteratorback to summary
public ChannelsReadOnlyIterator(Iterable<T> channelIterable)

Method Detail

emptyback to summary
public static <T> Iterator<T> empty()
Annotations
@SuppressWarnings:unchecked
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Channel next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Channel

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override