Chris Brody, el 14 de diciembre a las 11:29 me escribiste:
> On 12/14/07, Leandro Lucarella <[EMAIL PROTECTED]> wrote:
> [...]
> > I don't completely understand what's your plan, but I was planning to make
> > a C++ libev (native API) wrapper in the style of eventxx in the, hopefuly,
> > short term. Is that what you plan to do?
> 
> Leandro, can you please announce it if you do this?

Sure.

> My desire is to have 2 wrappers, one over the "classic" libevent API
> (using eventxx) and one that only requires libev API, but can be
> interchanged very easily. This could make it easier for certain
> applications to migrate and take advantage of the improvements in the
> libev API.

I don't think I will point in that direction. If I do the libev wrapper,
I probably will do it in the spirit of eventxx, to be as close as the
"host" API as possible. If you want to use libev in a libevent fashion,
you can already do that using the libevent emulation layer of libev.

> If you look in the project, there is a "ioevent" API that extends
> eventxx and also io++.h which tries to emulate a similar API over
> ev++.h.
> 
> Perhaps some of my work should be taken as suggestions for possible
> enhancements to the original (eventxx and ev++) authors.

Thinking out loud, this is roughtly what I have in mind for evxx =)

First I have to figure out what to do with all the compile-time
configuration that libev provide, I don't know if I will support all the
configuration options.

I want to be able to do something like this with evxx (based on the
libev example):

Multiple loop mode (the closest to libevent):


// Maybe some define.
#include <evxx>

/* called when data readable on stdin */
static void
stdin_cb(evxx::loop& l, evxx::cio& w, int revents)
{
        /* puts ("stdin ready"); */
        w.stop(l); /* just a syntax example */
        l.unloop(evxx::UNLOOP_ALL); /* leave all loop calls */
}

static void
timeout_cb(evxx::loop& l, evxx::ctimer& w, int revents)
{
        /* puts ("timeout"); */
        l.unloop(evxx::UNLOOP_ONE); /* leave one loop call */
}

int
main(void)
{
        evxx::loop loop;

        /* initialise an io watcher, then start it */
        evxx::cio stdin_watcher(stdin_cb, /*STDIN_FILENO*/ 0, evxx::READ);
        stdin_watcher.start(loop);

        /* simple non-repeating 5.5 second timeout */
        evxx::ctimer timeout_watcher(timeout_cb, 5.5, 0.);
        timeout_watcher.start(loop);

        /* loop till timeout or data ready */
        loop.loop();

        return 0;
}

Methods callbacks should be supported too, as in eventxx.

And here's an idea about ho a single loop mode can be handled (but I'm not
sure I will support this mode):

#include <evxx>

/* called when data readable on stdin */
static void
stdin_cb (evxx::cio& w, int revents)
{
        /* puts ("stdin ready"); */
        w.stop(); /* just a syntax example */
        evxx::unloop(evxx::UNLOOP_ALL); /* leave all loop calls */
}

static void
timeout_cb (evxx::ctimer& w, int revents)
{
        /* puts ("timeout"); */
        evxx::unloop(evxx::UNLOOP_ONE); /* leave one loop call */
}

int
main (void)
{
        evxx::init();

        /* initialise an io watcher, then start it */
        evxx::cio stdin_watcher(stdin_cb, /*STDIN_FILENO*/ 0, evxx::READ);
        stdin_watcher.start();

        /* simple non-repeating 5.5 second timeout */
        evxx::ctimer timeout_watcher(timeout_cb, 5.5, 0.);
        timeout_watcher.start();

        /* loop till timeout or data ready */
        evxx::loop();

        return 0;
}


I think to multiple vs. single loop configurability is great, but it's a
little complex when using as a shared library and for making distribution
binary packages, since the API changes with that configuration.

Is there any chance to consider mantaining the API besides any
configuration diferences? I think writing an extra loop parameter even
when you are using the single loop mode worth the consistency gain and
maintainance simplicity.

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Lo último que hay que pensar es que se desalinea la memoria
Hay que priorizar como causa la idiotez propia
Ya lo tengo asumido
        -- Pablete, filósofo contemporáneo desconocido

_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to