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的策略;