public class ThreadPerChannelEventLoopGroup extends AbstractEventExecutorGroup implements EventLoopGroup
Modifier | Constructor and Description |
---|---|
protected |
ThreadPerChannelEventLoopGroup()
Create a new
ThreadPerChannelEventLoopGroup with no limit in place. |
protected |
ThreadPerChannelEventLoopGroup(int maxChannels)
Create a new
ThreadPerChannelEventLoopGroup . |
protected |
ThreadPerChannelEventLoopGroup(int maxChannels,
Executor executor,
Object... args)
Create a new
ThreadPerChannelEventLoopGroup . |
protected |
ThreadPerChannelEventLoopGroup(int maxChannels,
ThreadFactory threadFactory,
Object... args)
Create a new
ThreadPerChannelEventLoopGroup . |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
<E extends EventExecutor> |
children()
Returns the unmodifiable set of
EventExecutor s managed by this EventExecutorGroup . |
boolean |
isShutdown() |
boolean |
isShuttingDown()
Returns
true if and only if all EventExecutor s managed by this EventExecutorGroup
are being shut down gracefuclly or was shut down. |
boolean |
isTerminated() |
protected EventLoop |
newChild(Object... args)
Creates a new
EventLoop . |
EventLoop |
next()
Returns one of the
EventExecutor s managed by this EventExecutorGroup . |
ChannelFuture |
register(Channel channel)
|
ChannelFuture |
register(Channel channel,
ChannelPromise promise)
|
void |
shutdown()
Deprecated.
|
Future<?> |
shutdownGracefully(long quietPeriod,
long timeout,
TimeUnit unit)
Signals this executor that the caller wants the executor to be shut down.
|
Future<?> |
terminationFuture()
Returns the
Future which is notified when all EventExecutor s managed by this
EventExecutorGroup have been terminated. |
close, execute, invokeAll, invokeAll, invokeAny, invokeAny, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submit
invokeAll, invokeAll, invokeAny, invokeAny
close
protected ThreadPerChannelEventLoopGroup()
ThreadPerChannelEventLoopGroup
with no limit in place.protected ThreadPerChannelEventLoopGroup(int maxChannels)
ThreadPerChannelEventLoopGroup
.maxChannels
- 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(Channel, ChannelPromise)
method.
Use 0
to use no limitprotected ThreadPerChannelEventLoopGroup(int maxChannels, ThreadFactory threadFactory, Object... args)
ThreadPerChannelEventLoopGroup
.maxChannels
- 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(Channel, ChannelPromise)
method.
Use 0
to use no limitthreadFactory
- the ThreadFactory
used to create new Thread
instances that handle the
registered Channel
sargs
- arguments which will passed to each newChild(Object...)
call.protected ThreadPerChannelEventLoopGroup(int maxChannels, Executor executor, Object... args)
ThreadPerChannelEventLoopGroup
.maxChannels
- 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(Channel, ChannelPromise)
method.
Use 0
to use no limitexecutor
- the Executor
used to create new Thread
instances that handle the
registered Channel
sargs
- arguments which will passed to each newChild(Object...)
call.protected EventLoop newChild(Object... args) throws Exception
EventLoop
. The default implementation creates a new ThreadPerChannelEventLoop
.Exception
public <E extends EventExecutor> Set<E> children()
EventExecutorGroup
EventExecutor
s managed by this EventExecutorGroup
.children
in interface EventExecutorGroup
public EventLoop next()
EventExecutorGroup
EventExecutor
s managed by this EventExecutorGroup
.next
in interface EventLoopGroup
next
in interface EventExecutorGroup
public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit)
EventExecutorGroup
EventExecutorGroup.isShuttingDown()
starts to return true
, and the executor prepares to shut itself down.
Unlike EventExecutorGroup.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.shutdownGracefully
in interface EventExecutorGroup
quietPeriod
- the quiet period as described in the documentationtimeout
- the maximum amount of time to wait until the executor is EventExecutorGroup.shutdown()
regardless if a task was submitted during the quiet periodunit
- the unit of quietPeriod
and timeout
EventExecutorGroup.terminationFuture()
public Future<?> terminationFuture()
EventExecutorGroup
Future
which is notified when all EventExecutor
s managed by this
EventExecutorGroup
have been terminated.terminationFuture
in interface EventExecutorGroup
@Deprecated public void shutdown()
shutdown
in interface EventExecutorGroup
shutdown
in interface ExecutorService
shutdown
in class AbstractEventExecutorGroup
public boolean isShuttingDown()
EventExecutorGroup
true
if and only if all EventExecutor
s managed by this EventExecutorGroup
are being shut down gracefuclly or was shut down.isShuttingDown
in interface EventExecutorGroup
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public ChannelFuture register(Channel channel)
EventLoopGroup
Channel
with an EventLoop
from this EventLoopGroup
. The returned
ChannelFuture
will get notified once the registration is completed.
It's only safe to submit a new task to the EventLoop
from within a
ChannelHandler
once the ChannelPromise
succeeded. Otherwise
the task may or may not be rejected.
register
in interface EventLoopGroup
public ChannelFuture register(Channel channel, ChannelPromise promise)
EventLoopGroup
Channel
with an EventLoop
from this EventLoopGroup
. The provided
ChannelPromise
will get notified once the registration is completed. The returned ChannelFuture
is the same ChannelPromise
that was passed to the method.
It's only safe to submit a new task to the EventLoop
from within a
ChannelHandler
once the ChannelPromise
succeeded. Otherwise
the task may or may not be rejected.
register
in interface EventLoopGroup
Copyright © 2008–2015 The Netty Project. All rights reserved.