New iteration over the ev++ improvement patch.

Marc Lehmann schmorp at
Fri Jan 18 06:08:38 CET 2008

On Thu, Jan 17, 2008 at 05:08:16PM -0200, Leandro Lucarella <llucax at> wrote:
> 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 =)

the "recursion" is fine, overriding throw isn't, because:

a) you sometimes use a zero-argument form of throw()
b) overriding throw isn't really legal
c) never override stuff the uer validly might have overridden herself already

> * Back to a loop_ref + dynamic_loop + default_loop scheme.

Sounds good. Time will tell wether it was the right decision :)

>   - dynamic_loop and default_loop have both reference semantics (they are
>     non-copiable and non-assignable), and provide automatic destruction.

very good.

>   - 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?).

right now, calling ev_default_destroy twice is a bug. this is safe, however:

   ev_default_init (0); ev_default_destroy ()

I think at first we should do it that way, we can simplify later,
together with changing ev_default_* into aliases to the ev_loop functions

> * 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).

Lets keep it thsi way till it works and then optimise :)

> * 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.

Can't help it, I still am not sure we should provide an actual default
loop wrapper, as I think the default loop is a shared resource that is not
controlled by any one instance.

> * loop_ref::fork() is now named loop_ref::fix_fork().

try post_fork, it doesn't really fix any fork thing :)

> * ev::time() is now named ev::now().

bad idea, now "now" means something for C, and something else for
C++.  I would expect ev::now() to do mostly the same as ev_now ().

> * ev::sleep() is now named ev::delay() (stolen from SDL ;).

ah well :)

I wonder wether we shouldn't use some prefix instead instead of renaming
all symbols.

> 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.

You can just apply it yourself in one go. We can then change it from that

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list