Douglas C. Schmidt 1995年提出:数组
An Object Behavioral Pattern for Demultiplexing and
Dispatching Handles for Synchronous Events
Scalable IO in Java - Doug Lea
网络
http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf
基于Java IO对Reactor模式进行阐述
NIO 网络框架的典型模式多线程
Mina、Netty、Cindy 都是此模式的实现
Douglasapp
单线程框架
多线程 Reactoride
Multiple Reactoroop
其余主从形式,可是不经常使用spa
单线程的Reactor线程
EventLoopGroup eventExecutors = new NioEventLoopGroup(1);
ServerBootstrap serverBootstrap = new ServerBootstrap().group(eventExecutors,eventExecutors);
多线程3d
EventLoopGroup eventExecutors = new NioEventLoopGroup(1);
ServerBootstrap serverBootstrap = new ServerBootstrap().group(eventExecutors,eventExecutors);//Handler使用线程池进行处理
Multiple Reactor
EventLoopGroup eventExecutors = new NioEventLoopGroup(1);
EventLoopGroup workereventExecutors = new NioEventLoopGroup();
ServerBootstrap serverBootstrap = new ServerBootstrap().group(eventExecutors,workereventExecutors);
EventLoopGroup eventExecutors = new NioEventLoopGroup();
EventLoopGroup workereventExecutors = new NioEventLoopGroup();
ServerBootstrap serverBootstrap = new ServerBootstrap().group(eventExecutors,workereventExecutors);
EventExecutor视图
EventExecutorGroup里面有一个EventExecutor数组,保存了多个EventExecutor;
EventExecutorGroup是不干什么事情的,当收到一个请后,他就调用next()得到一个它里面的EventExecutor,再调用这个executor的方法;
next(): EventExecutorChooser.next()定义选择EventExecutor的策略;