Commit Briefs
ev: add signal() to catch signals safely too
Uses the 'self-pipe trick' to catch and process signals outside of the signal environment. A few XXX remains, but this is good enough to hit the tree.
ev: move some functions to ev/global.ha
Move there functions that relies on the global event loop.
ev: rework the API
Allow to create custom event loops, but still retain the possibility to just use a global one.
ev: inline use nullable *opaque instead of ev::any
ev::any was just to save some typing; not sure it's worth it. Can be easily confused with ev::READ and ev::WRITE.
ev: use def instead of const for globals
I actually don't get the difference between def and const. maybe def is guaranteed to be a compile-time constant (just guessing). Other "#defines" in the hare stdlib seem to use def tho, so follow here too.
ev: use two queues
avoids issues with adding/removing elements from the 'working' queue. ev::add and ev::del only touch the "wip" queue, while poll only touches the "working" queue. This technically has the consequences that if from event A we remove event B which is pending and not yet processed, we may still fire B once.
ev: process all the events
This was intended as an optimization: poll returns the number of elements in the pollfd set which had events. Can be revised in the future.