Libevent Analysis Notes (3) - Determining I/O Multiplexing Mechanism
Libevent’s original intention was to design a cross-platform lightweight I/O framework. Due to historical issues, the I/O multiplexing mechanisms across different platforms are difficult to unify. Therefore, the methods for handling cross-platform compatibility deserve special attention.
eventop is defined in the source code as follows:
|
|
As can be seen, libevent uses macros to find available multiplexing mechanisms at compile time.
The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts.
The libevent API provides such a mechanism:


{
if( n == 1)
}