Search This Blog

2023/04/13

Reactor Pattern

 1)The application generates a new I/O operation by submitting a request to the Event Demultiplexer.The application also specifies a handler, which will be invoked when the operation completes. Submitting a new request to the Event Demultiplexer is a non-blocking call and it immediately returns control to the application.


2)When a set of I/O operations completes, the Event Demultiplexer pushes a set of corresponding events into the Event Queue.

3)At this point, the Event Loop iterates over the items of the Event Queue.

4)For each event, the associated handler is invoked.

5)The handler, which is part of the application code, gives back control to the Event Loop when its execution completes (5a). While the handler executes, it can request new asynchronous operations (5b), causing new items to be added to the Event Demultiplexer (1).

6)When all the items in the Event Queue are processed, the Event Loop blocks again on the Event Demultiplexer, which then triggers another cycle when a new event is available.




No comments:

Post a Comment