Top Description Fields Constructors Methods
io.netty.channel

public Class ThreadPerChannelEventLoopGroup

extends AbstractEventExecutorGroup
implements EventLoopGroup
Class Inheritance
All Implemented Interfaces
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
Known Direct Subclasses
io.netty.channel.oio.OioEventLoopGroup
Annotations
@Deprecated
Imports
io.netty.util.concurrent.AbstractEventExecutorGroup, .DefaultPromise, .DefaultThreadFactory, .EventExecutor, .Future, .FutureListener, .GlobalEventExecutor, .Promise, .ThreadPerTaskExecutor, io.netty.util.internal.EmptyArrays, .ObjectUtil, .PlatformDependent, .ReadOnlyIterator, java.util.Collections, .Iterator, .Queue, .Set, java.util.concurrent.ConcurrentLinkedQueue, .Executor, .RejectedExecutionException, .ThreadFactory, .TimeUnit

Deprecated

this will be remove in the next-major release.

An EventLoopGroup that creates one EventLoop per Channel.

Field Summary

Modifier and TypeField and Description
pack-priv final Set<EventLoop>
private final Object[]
private final FutureListener<Object>
pack-priv final Executor
pack-priv final Queue<EventLoop>
private final int
private volatile boolean
private final Promise<?>
private final ChannelException

Constructor Summary

AccessConstructor and Description
protected
ThreadPerChannelEventLoopGroup()

Create a new ThreadPerChannelEventLoopGroup with no limit in place.

protected
ThreadPerChannelEventLoopGroup(int
the maximum number of channels to handle with this instance. Once you try to register a new Channel and the maximum is exceed it will throw an ChannelException. on the register(Channel) and register(ChannelPromise) method. Use 0 to use no limit
maxChannels
)

Create a new ThreadPerChannelEventLoopGroup.

protected
ThreadPerChannelEventLoopGroup(int
the maximum number of channels to handle with this instance. Once you try to register a new Channel and the maximum is exceed it will throw an ChannelException on the register(Channel) and register(ChannelPromise) method. Use 0 to use no limit
maxChannels
,
ThreadFactory
the ThreadFactory used to create new Thread instances that handle the registered Channels
threadFactory
,
Object...
arguments which will passed to each newChild(Object...) call.
args
)

Create a new ThreadPerChannelEventLoopGroup.

protected
ThreadPerChannelEventLoopGroup(int
the maximum number of channels to handle with this instance. Once you try to register a new Channel and the maximum is exceed it will throw an ChannelException on the register(Channel) and register(ChannelPromise) method. Use 0 to use no limit
maxChannels
,
Executor
the Executor used to create new Thread instances that handle the registered Channels
executor
,
Object...
arguments which will passed to each newChild(Object...) call.
args
)

Create a new ThreadPerChannelEventLoopGroup.

Method Summary

Modifier and TypeMethod and Description
public boolean
awaitTermination(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
public boolean
isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.
public boolean
public boolean
isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down.
public Iterator<EventExecutor>
iterator()

Implements io.netty.util.concurrent.EventExecutorGroup.iterator.

Returns an iterator over elements of type T.
protected EventLoop
newChild(Object... args)

Creates a new EventLoop.

public EventLoop
private EventLoop
public ChannelFuture
public ChannelFuture
public ChannelFuture
register(Channel channel, ChannelPromise promise)

Implements io.netty.channel.EventLoopGroup.register.

Deprecated
Register a Channel with this EventLoop.
public void
shutdown()

Implements abstract io.netty.util.concurrent.AbstractEventExecutorGroup.shutdown.

Implements io.netty.util.concurrent.EventExecutorGroup.shutdown.

Deprecated
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
public Future<?>
shutdownGracefully(long
the quiet period as described in the documentation
quietPeriod
,
long
the maximum amount of time to wait until the executor is shutdown() regardless if a task was submitted during the quiet period
timeout
,
TimeUnit
the unit of quietPeriod and timeout
unit
)

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

Signals this executor that the caller wants the executor to be shut down.
public Future<?>
terminationFuture()

Implements io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.
Inherited from io.netty.util.concurrent.AbstractEventExecutorGroup:
executeinvokeAllinvokeAllinvokeAnyinvokeAnyscheduleschedulescheduleAtFixedRatescheduleWithFixedDelayshutdownGracefullyshutdownNowsubmitsubmitsubmit

Field Detail

activeChildrenback to summary
pack-priv final Set<EventLoop> activeChildren
childArgsback to summary
private final Object[] childArgs
childTerminationListenerback to summary
private final FutureListener<Object> childTerminationListener
executorback to summary
pack-priv final Executor executor
idleChildrenback to summary
pack-priv final Queue<EventLoop> idleChildren
maxChannelsback to summary
private final int maxChannels
shuttingDownback to summary
private volatile boolean shuttingDown
terminationFutureback to summary
private final Promise<?> terminationFuture
tooManyChannelsback to summary
private final ChannelException tooManyChannels

Constructor Detail

ThreadPerChannelEventLoopGroupback to summary
protected ThreadPerChannelEventLoopGroup()

Create a new ThreadPerChannelEventLoopGroup with no limit in place.

ThreadPerChannelEventLoopGroupback to summary
protected ThreadPerChannelEventLoopGroup(int maxChannels)

Create a new ThreadPerChannelEventLoopGroup.

Parameters
maxChannels:int

the maximum number of channels to handle with this instance. Once you try to register a new Channel and the maximum is exceed it will throw an ChannelException. on the register(Channel) and register(ChannelPromise) method. Use 0 to use no limit

ThreadPerChannelEventLoopGroupback to summary
protected ThreadPerChannelEventLoopGroup(int maxChannels, ThreadFactory threadFactory, Object... args)

Create a new ThreadPerChannelEventLoopGroup.

Parameters
maxChannels:int

the maximum number of channels to handle with this instance. Once you try to register a new Channel and the maximum is exceed it will throw an ChannelException on the register(Channel) and register(ChannelPromise) method. Use 0 to use no limit

threadFactory:ThreadFactory

the ThreadFactory used to create new Thread instances that handle the registered Channels

args:Object[]

arguments which will passed to each newChild(Object...) call.

ThreadPerChannelEventLoopGroupback to summary
protected ThreadPerChannelEventLoopGroup(int maxChannels, Executor executor, Object... args)

Create a new ThreadPerChannelEventLoopGroup.

Parameters
maxChannels:int

the maximum number of channels to handle with this instance. Once you try to register a new Channel and the maximum is exceed it will throw an ChannelException on the register(Channel) and register(ChannelPromise) method. Use 0 to use no limit

executor:Executor

the Executor used to create new Thread instances that handle the registered Channels

args:Object[]

arguments which will passed to each newChild(Object...) call.

Method Detail

awaitTerminationback to summary
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.ExecutorService.awaitTermination.

Doc from java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:boolean

true if this executor terminated and false if the timeout elapsed before termination

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
isShutdownback to summary
public boolean isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Doc from java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.

Returns:boolean

true if this executor has been shut down

Annotations
@Override
isShuttingDownback to summary
public boolean isShuttingDown()

Implements io.netty.util.concurrent.EventExecutorGroup.isShuttingDown.

Doc from io.netty.util.concurrent.EventExecutorGroup.isShuttingDown.

Returns true if and only if all EventExecutors managed by this EventExecutorGroup are being shut down gracefully or was shut down.

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Doc from java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down. Note that isTerminated is never true unless either shutdown or shutdownNow was called first.

Returns:boolean

true if all tasks have completed following shut down

Annotations
@Override
iteratorback to summary
public Iterator<EventExecutor> iterator()

Implements io.netty.util.concurrent.EventExecutorGroup.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<EventExecutor>

an Iterator.

Annotations
@Override
newChildback to summary
protected EventLoop newChild(Object... args) throws Exception

Creates a new EventLoop. The default implementation creates a new ThreadPerChannelEventLoop.

nextback to summary
public EventLoop next()

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

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

Return the next EventLoop to use

Annotations
@Override
nextChildback to summary
private EventLoop nextChild() throws Exception
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(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(Channel channel, 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
shutdownback to summary
public void shutdown()

Implements abstract io.netty.util.concurrent.AbstractEventExecutorGroup.shutdown.

Implements io.netty.util.concurrent.EventExecutorGroup.shutdown.

Doc from java.util.concurrent.ExecutorService.shutdown.

Deprecated

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.

This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

Annotations
@Override
@Deprecated
shutdownGracefullyback to summary
public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit)

Implements io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

Doc from io.netty.util.concurrent.EventExecutorGroup.shutdownGracefully.

Signals this executor that the caller wants the executor to be shut down. Once this method is called, isShuttingDown() starts to return true, and the executor prepares to shut itself down. Unlike shutdown(), graceful shutdown ensures that no tasks are submitted for 'the quiet period' (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period, it is guaranteed to be accepted and the quiet period will start over.

Parameters
quietPeriod:long

the quiet period as described in the documentation

timeout:long

the maximum amount of time to wait until the executor is shutdown() regardless if a task was submitted during the quiet period

unit:TimeUnit

the unit of quietPeriod and timeout

Returns:Future<?>

the terminationFuture()

Annotations
@Override
terminationFutureback to summary
public Future<?> terminationFuture()

Implements io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

Doc from io.netty.util.concurrent.EventExecutorGroup.terminationFuture.

Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.

Annotations
@Override