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.
http://www.monkey.org/~provos/libevent/