Reactor模型
The reactor design pattern is an event handling pattern for handling service requests
delivered concurrently to a service handler by one or more inputs. The service handler
then demultiplexes the incoming requests and dispatches them synchronously to the
associated request handlers.
反应器设计模式是用于处理服务请求的事件处理模式由一个或多个输入并发地交付给服务处理程序。服务处理程序然后将传入的请求解复用,并将它们同步地分发到相关的请求处理程序。
重要组件: Event事件、Reactor反应堆、Demultiplex事件分发器、Evanthandler事件处理器
2、Single Reactor
在整个的基于Reactor模型的网络服务请在交互的时候:
首先,我们把事件注册到反应堆上,也就是说,应用程序对这个事件感兴趣,请求反应堆帮忙来监听它所感兴趣的事件,并且在这个事件发生的时候调用相应的预置的回调Handler;
向反应堆注册事件,就是把这个事件event和对应的handler(就是图中的Eventhandler&#