ev_set_loop_release_cb with class member functions.

Marc Lehmann schmorp at schmorp.de
Tue Jul 27 16:19:12 CEST 2010


On Tue, Jul 27, 2010 at 03:47:36PM +0900, Horacio Sanson <hsanson at gmail.com> wrote:
> I am trying to make my server class threaded following the thread example in the
> libev documentation. Unfortunately I am having some problems converting the C to
> C++ especially with the ev_set_loop_release_cb call.

Not sure what you mean converting C to C++ - libev already is C++, so
there is no need to convert anything.

> libevtest.cpp: In constructor ‘Server::Server()’:
> libevtest.cpp:37: error: cannot convert ‘void (Server::*)(ev_loop*)’ to ‘void
> (*)(ev_loop*)’ for argument ‘2’ to ‘void ev_set_loop_release_cb(ev_loop*, void
> (*)(ev_loop*), void (*)(ev_loop*))’

Yup, the types don't match - ev_set_loop_release_cb expects a function -
you would need to declare your lock and unlock functions as static. You
can set and query an object for example by passing it to ev_set_userdata
and fetching it via ev_userdata from your static member functions.

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



More information about the libev mailing list