New iteration over the ev++ improvement patch.

Leandro Lucarella llucax at gmail.com
Mon Jan 21 15:43:15 CET 2008


Leandro Lucarella, el 21 de enero a las 11:30 me escribiste:
> Marc Lehmann, el 21 de enero a las 06:20 me escribiste:
> > > > 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
> > 
> > "Want" is the wrong word, but it would enbale us to use struct loop in place
> > of struct loop_ref.
> 
> But it will forbids us to use the name loop for the watcher's variable.
> 
> > > I don't think it does. At least my trivial testcase got the linking
> > > error with GCC.
> > 
> > http://ue.tst.eu/3bb204f88a49475421615172f2ea7516.txt
> > 
> > I would really be interested in your trivial case and the linking error you
> > get. static variables *must* not collide, they are private to the translation
> > unit.
> 
> Ups! I didn't saw the magic word static :)
> 
> I don't think it's that nice to compulsively add a variable to each
> translation unit, but since it doesn't take any space is not that bad.

If we assume we can do that, why don't just making the old default_loop
instantiated as a static global variable? That way is more
straightforward.

I've implemented that and it works (and looks, at least for me) just fine.

Patch:
http://git.llucax.com.ar/?p=software/libev.git;a=commitdiff;h=10971528d99cd30d0b09f7b44c434a15d6c4327c
Example:
http://git.llucax.com.ar/?p=software/libev.git;a=blob;f=test.cpp;h=d7c12e7c1ce33d426df6cba57d9ed571f53345bc;hb=2c1a7ea812881c88853408b5f248307922f66ac4

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
- Los romanos no tenían paz, loco... Necesitaban un poco de chala...




More information about the libev mailing list