New iteration over the ev++ improvement patch.

Leandro Lucarella llucax at
Mon Jan 21 06:02:54 CET 2008

Marc Lehmann, el 21 de enero a las 05:44 me escribiste:
> On Sun, Jan 20, 2008 at 04:51:02PM -0200, Leandro Lucarella <llucax at> wrote:
> > >   static struct
> > >   {
> > >     operator loop_ref () { return ...; }
> > >   } default_loop;
> > > 
> > > would be interesting to see what kinds of overhead this creates, if any.
> > 
> > I don't think it's going to work. Even if that struct takes no space, you
> > get a multiple definition error when linking multiple translation units.
> That would be a major bug in the compiler and/or linker? I doubt you will
> find a compiler that buggy nowadays.

GCC is that "buggy". But I don't think is a bug, because a variable has to
be addressable so it has to ocupy some space or at least point an unique
fake address :)

> > And then, it would be useful only for passing arround since to call any
> > methods you'll have to do something like
> > ev::loop_ref(ev::default_loop).method();
> Let's wait for c++0x and lets overwrite the . operator then. Or override
> the -> operator now:
>   ev_io myio (ev::default_loop);
>   myio.start (...);
>   ev::default_loop->run ();

It looks like you want me to rename loop() to run() =P

> Looks fine and sensible to me.

Not bad, but we still have the link problem...

> > But it would be so nice if we can sort out a way to use the default_loop
> > as an object.
> I think the above works.

I don't think it does. At least my trivial testcase got the linking
error with GCC.

> > We should provide an initialization method for the default loop and make
> > the default constructor a NOP though.
> The problem with thta is that you have no control over construction order
> and flags.

If we do what I said in the above paragraph, you have.

Leandro Lucarella (luca) | Blog colectivo:
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
Con todas las manos que me acogotan, no puedo respirar
Con todos sus dedos me haría una torta, para festejar
Que no me estoy yendo solo de este lugar

More information about the libev mailing list