Reactor pattern
The reactor pattern is used to handle service requests that are received concurrently by a service handler from a single or multiple input sources. The received service requests are then demultiplexed by the service handler and dispatched to the associated request handlers. All the reactor systems are commonly found in single threads, but they are also said to exist in a multi-threaded environment.
The key benefit of using this pattern is that the application components can be divided into multiple parts such as modular or reusable. Furthermore, this allows simple coarse-grain concurrency without the additional complexity of multiple threads to the system.
Let's see the following diagram about the reactor design pattern:
As you can see in the preceding diagram, the dispatcher uses the demultiplexer to notify handler and the handler performs the actual work to be done with an I/O event. A reactor responds to I/O events by dispatching the appropriate handler. Handlers perform...