1、EventExecutorGroup使用它的next()方法负责提供EventExecutor,除此之外,负责生命周期的任务处理,允许以全局方式关闭所有任务(The EventExecutorGroup
is responsible to provide EventExecutor
's to use via its next()
method. Beside this it also is responsible to handle their live-cycle and allows to shut them down in a global fashion.)
public interface EventExecutorGroup extends ScheduledExecutorService {}
2、
EventLoopGroup 继承自EventExecutorGroup, 并提供EventLoop的生成方法next()(Special EventExecutorGroup
which allows to register Channel
's that get processed for later selection during the event loop.)
public interface EventLoopGroup extends EventExecutorGroup {
@Override
EventLoop next();
}
3、
EventLoop的英文解释是:Will handle all the I/O-Operations for a Channel once it was registered,即处理channel的io操作(
Will handle all the I/O-Operations for a
Channel
once it was registered. One
EventLoop
instance will usually handle more then one
Channel
but this may depend on implementation details and internals.
)
public interface EventLoop extends EventExecutor, EventLoopGroup {
@Override
EventLoopGroup parent();
@Override
EventLoop next();
/**
* Creates a new default {@link ChannelHandlerInvoker} implementation that uses this {@link EventLoop} to
* invoke event handler methods.
*/
ChannelHandlerInvoker asInvoker();
}
EventLoop 首先是一个Executor,任务执行器。 再者它本身是一个环,能够负载均衡执行压力。可以说EventLoop是Netty的一个核心,整个Netty的运转都是围绕着它。( http://www.cxyclub.cn/n/36389/)
EventLoop还继承了EventExecutor,下面看看吧
4、EventExecutor 是一个特殊的EventExecutorGroup,提供了检测一个线程是否在eventLoop中被执行之类的方法.
(The EventExecutor
is a special EventExecutorGroup
which comes with some handy methods to see if a Thread
is executed in a event loop. Beside this it also extends the EventExecutorGroup
to allow a generic way to access methods.)
public interface EventExecutor extends EventExecutorGroup{}
从这些方法,我们可以清晰的认识到EventLoop可以实现以下功能:
1. 执行任务(IO/非IO任务)
2. 将Channel绑定到EventLoop上
3. 执行定时任务
4. 关闭任务