minimiolibrary, an extremely simplified version of a cross platform event queue. I actually encourage you to clone or fork the repository and play around with the code as we go through.
Pollstructure is the heart of our event queue. This structure implements one important method:
poll(). When called this method tells the OS "I want you to park the thread I'm in, work on something else, and wake me up when one of the events I told you I'm interested in is ready".
Registratorhas one job. It tells our operating system that we're interested in an event. An example of this is when data is ready for us to read on a network socket. The
Registratoris tied to
Pollin the sense that we want the OS to wake us up from the call to
poll()when the event is ready. Every event queue has an ID that is unique. Typically,
Pollis on two different threads.
Pollcan wait for any type of event it supports. Some examples of this is
Writeevents on a socket or a pipe. These types of events depend on what kind of resource we're working with. Timeouts are another type of event which most systems support.
TcpStream(or any other resource)
IOCP. We'll only cover the case of being interested in
Readevents on the
TcpStreambut this is only limited to what kind of resources the OS allows us to register interests on.