码迷,mamicode.com
首页 > 其他好文 > 详细

reactor design pattern

时间:2015-01-07 19:22:10      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

reactor design pattern


详见:http://en.wikipedia.org/wiki/Reactor_pattern


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.


Properties

All reactor systems are single threaded by definition, but can exist in a multithreaded environment.


Benefits

The reactor pattern completely separates application specific code from the reactor implementation, which means that application components can be divided into modular(模块化), reusable(可复用的) parts. Also, due to the synchronous calling of request handlers, the reactor pattern allows for simple coarse-grain concurrency while not adding the complexity of multiple threads to the system.


Limitations

The reactor pattern can be more difficult to debug than a procedural pattern due to the inverted flow of control. Also, by only calling request handlers synchronously, the reactor pattern limits maximum concurrency, especially on Symmetric multiprocessing hardware. The scalability of the reactor pattern is limited not only by calling request handlers synchronously, but also by the demultiplexer. 


最后看一个在网络编程中的Reactor模式示意图,

技术分享


=========================END=========================


reactor design pattern

标签:

原文地址:http://my.oschina.net/xinxingegeya/blog/364816

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!