Well, after all the talking and thinking, this is what I came up with.
Main changes:
* The use of exceptions is now optional (configurable via
EV_CXX_EXCEPTIONS). I don't know if:
#define throw(exception) throw (exception)
is valid preprocesor code though =)
It could be easily changed to EV_THROW or something but I wanted to keep
the syntax highlight ;)
* All the macro constant -> enum translation is moved to the top.
* Back to a loop_ref + dynamic_loop + default_loop scheme.
- loop_ref has value semantics and is just a pointer wrapper (but with
reference syntax ;). You can change a ev_loop* and a loop_ref without
notice. You can create (or asign) a loop_ref from a ev_loop* and you
can cast a loop_ref to a ev_loop*. You can check for equality between
loop_refs and ev_loop pointers.
- dynamic_loop and default_loop have both reference semantics (they are
non-copiable and non-assignable), and provide automatic destruction.
- No check is done when creating a default_loop to see if one is already
created (could be trouble if ev_default_destroy() is called more than
once?).
* loop_ref::is_default() is provided using ev_default_loop in the meantime
to implement fork() and destroy() in loop_ref (waiting to see if
ev_loop_{fork,destroy} would accept a default or dynamic loop
indistinctly).
* A new function ev::get_default_loop () is provided to get a loop_ref to
the default loop. Once again, no check is done to ensure this function
wont get called before actually creating the default loop.
* loop_ref::fork() is now named loop_ref::fix_fork().
* ev::time() is now named ev::now().
* ev::sleep() is now named ev::delay() (stolen from SDL ;).
* Watchers now store a loop_ref. Since you can assign a ev_loop* to a
loop_ref, everybody should be happy now.
Patch and example attached. Documentation still missing (I'll do that when
the patch gets a technical OK =). I'll probably split the patch in
smaller, incremental changes.
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
- i bet microsoft's developers were on diet when they had to do win95
- microsoft has developers?
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev