Reactor pattern is explained in wikipedia, and it's a bit too abstract. Can you describe this pattern in a more concrete way? Ideally with code snippets or high-level class diagrams describing some applications of 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.
The purpose of the Reactor design pattern is to avoid the common problem of creating a thread for each message, request, and connection. Then it receives events from a set of handlers and distributes them sequentially to the corresponding event handlers.
Reactor Pattern is used to avoid the blocking of the Input/Output operations. It provides us with a handler that is associated with I/O operations.
Event Loop checks the event queue, picks the event and provides result to its callback handler. The event loop send the response to the application by callback handler or stores another event in the event demultiplexer. Event loop will run continuously and check the event queue until event queue get empty.
You might want to check the original paper describing it http://www.dre.vanderbilt.edu/~schmidt/PDF/reactor-siemens.pdf
The Reactor design pattern handles service requests that are delivered concurrently to an application by one or more clients. Each service in an application may consist of serveral methods and is represented by a separate event handler that is responsible for dispatching service-specific requests. Dispatching of event handlers is performed by an initiation dispatcher, which manages the registered event handlers. Demultiplexing of service requests is performed by a synchronous event demultiplexer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With