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

Leandro Lucarella llucax at gmail.com
Fri Jan 18 13:47:44 CET 2008


Marc Lehmann, el 18 de enero a las 06:13 me escribiste:
> On Wed, Jan 16, 2008 at 03:37:12PM -0200, Leandro Lucarella <llucax at gmail.com> wrote:
> > > Well, I think its a wonderful idea, its a loop, it should be called loop :)
> > 
> > If we call it loop, then the loop() method has to be called other way,
> > that's why I didn't call it loop. Maybe loop -> start, unloop -> stop
> > (like watchers? but since they are radically different methods, maybe the
> > must be called otherwise). Maybe just loop -> do_loop?
> 
>    loop::run () // flags=0
>    loop::one_iteration () // once
>    loop::sweep () // nonblock
> 
> would be possible :) Or even:
> 
>    loop ();
> 
> :->
> 
> the reason it is called ev_loop is caused by a limitation in C's object
> orientation, and I think we can get away with renaming it here (it
> actually is taken mostly from libevent, and today I think maybe its not
> that good an interface).
> 
> I am not saying we should rename it, its basically the question wether we
> want to use something ugly like loop_ref and a loop_ref::loop, or a loop,
> and a renamed (nut nice) loop::run ().

I would say you're right except for the reasons you gave in the other mail
(that most of the time you will not declare a loop_ref yourself). I
noticed you were right when coding the example. The only loop_refs objects
are there for testing purposes, but in real code I don't see it coming
into light very often.

Most of the time you'll do something like:
ev::default_loop loop;
loop.this ();
loop.that ();

void cb (watcher &w, int revents)
{
	w.loop.this ();
	w.loop.that ();
}

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
The world's best known word is "okay"
The second most well-known word is "Coca-Cola"




More information about the libev mailing list