[PS: I also sent a copy to the libev list as the libevent-like callback
might be of interest to others, hope that was OK]

On Tue, Dec 11, 2007 at 01:49:50PM +0100, Chris Brody <[EMAIL PROTECTED]> wrote:
> Much better, thank you!

1.8 should also have all these fixes, and of course a few others.

> I am happy to see a normal "C function" callback as well. I still
> stand by my earlier suggestion to allow a callback like: void func(int
> fd, short ev, void * args)... since this would make a much quicker C++
> drop-in replacement for libevent.

you can add it yourself "easily", in pseudo-code:

   struct my_io : ev::io
   {
     template<void (*function)(int, short, void *)>
     void set (void *data = 0)
     {
       set_ (data, libevent_thunk<function>);
     }
  
     template<void (*function)(int, short, void *)>
     static void libevent_thunk (EV_P_ ev_io *w, int revents)
     {
       function (w->fd, revents, w->data);
     }
   };

   myio.set <my_cb> (mydata);

all the goodies like inlining also apply to this, so there is, again very
little overhead (actually none as if the callback-calling-code would be
coded like in libevent (the ideal case for this example) it would still need
to load fd and data even if not used.

(if you use that, maybe I should rename the (currently internal) set_
function to set_cb or something).

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      [EMAIL PROTECTED]
      -=====/_/_//_/\_,_/ /_/\_\

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

Reply via email to