[RFC] extending ev++.h to add C++ loop wrappers.

Leandro Lucarella llucax at gmail.com
Fri Jan 18 13:59:03 CET 2008


Marc Lehmann, el 18 de enero a las 06:20 me escribiste:
> On Thu, Jan 17, 2008 at 10:28:16AM -0200, Leandro Lucarella <llucax at gmail.com> wrote:
> > > Bause I don't: I changed ->stat to ->update already and it sucks. The
> > > obvious method would be to call them ev_sleep etc. (haha).
> > 
> > do_/get_xxx? do_fork, do_sleep, get_time?
> > 
> > fix_fork? go_sleep? now? (note that the now that gets the loop time is in
> > the loop object in ev:: =)
> 
> I frankly don't know.
> 
> (as for now, I think then libev should have ev_now => ev_time, and ev_now
> => ev_loop_now, but thats ugly).
> 
> The prefix method, however ugly, is at leats consistent between C and C++.
> 
> But of course do_ is about the worst possible prefix. I can't come up with
> anything better, sorry.
> 
> I guess the total rename is mostly the way to go then, i.e. deviate as
> much as neccessary from the C API.

How about the names used in the patch?

> > > Another option would be to #undef sleep in the header file. Thats rather
> > > drastic however and some people will hate us for it.
> > 
> > Yeah, I think that would be pretty hardcore...
> 
> Says the guy who redefined throw().

-.-

> On Thu, Jan 17, 2008 at 10:46:52AM -0200, Leandro Lucarella <llucax at gmail.com> wrote:
> > > That is pretty dumb to begin with.
> > 
> > No, the problem is, for example:
> > 
> > void cb (ev::io &w, int revents)
> > {
> > 	w.loop->unloop();
> > 	delete w.loop;
> > }
> 
> Thats pretty dumb to begin with, yes: deleting a loop that is actively
> running in ev_loop *is* pretty dumb, and undefined behaviour will be the
> punishment.

Detail, details... make that: other_loop->unloop (); delete other_loop; =)

Anyway, the point that allways other_loop would be a dynamic_loop makes
the problem go away.

> > Can I rely on ev_loop_{fork,destroy} accepting default loops when
> > EV_MULTIPLICITY is set?
> 
> Definitely not, we should work aroundt hat way, even if inefficient, at the
> moment, and later redesign those functions and optimise the ev++.h use.

Is there any way to find out if a default loop is already initialized?

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Karma police
arrest this man,
he talks in maths,
he buzzes like a fridge,
he's like a detuned radio.




More information about the libev mailing list