New iteration over the ev++ improvement patch.

Leandro Lucarella llucax at gmail.com
Tue Jan 22 02:25:52 CET 2008


Marc Lehmann, el 21 de enero a las 18:11 me escribiste:
> On Mon, Jan 21, 2008 at 11:30:25AM -0200, Leandro Lucarella <llucax at gmail.com> wrote:
> > > "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.
> 
> Hmm, sounds like dejavu - why? The tag namespace and the member namespace
> are distinct.
> 
> It might result in ugly code, though, which would be enough of an agrument
> to put it off.

Well, the compiler complained about changing the meaning of loop in the
context of the watcher's base class, but adding the namespace to the type
when declaring the loop variable did the trick.

I'll commit this patch unless you have something against it:
http://git.llucax.com.ar/?p=software/libev.git;a=commitdiff;h=a11114f6c6a06077bcd9e208c064ebed9e577f8c

(I added operator () as an alias to run ()).

> > I find more natural to do (in C++):
> > ev::default_loop->init (flags);
> > than:
> > ev_default_init (flags);
> 
> I don't find anything natural at all at calling as do-called "init" method
> in C++, "shouldn't this be done by the constructor?" :)

Yes, but you didn't like the explicit default_loop instantiation =)
And the loop has to be initialized somewhere...

> In any case, I leave the final decision on how to implement this up to you :)

For the sake of simplicity I think I'll go with the global function
returning a loop_ref. It's the closest to C API so if someone don't like
it I can blame you =P

Seriously, I see 2 main use cases:
1) Use the default_loop just once, like the unloop() call in a callback.
2) Use the default_loop more often.

In case 1), the extra () is not such a big deal. In case 2), you'll
probably store the loop in a local variable for convenience (and/or
performance), so no problem there.

If that's ok with you, I'll apply this patch to CVS too:
http://git.llucax.com.ar/?p=software/libev.git;a=commitdiff;h=cb6fa5ebc2f52e7224708fecf85032342d8ebeb8

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
De las generaciones venideras espero, nada más, que vengan.
	-- Ricardo Vaporeso




More information about the libev mailing list