C++ How TO?

Praveen Baratam praveen.baratam+libev at gmail.com
Thu Dec 9 10:28:55 CET 2010


Hello All,

I am an absolute new comer to Libev and trying to use its c++ binding inside
my code.

There are very examples related to C++ binding.

All I can find was -

class myclass
   {
     ev::io   io  ; void io_cb   (ev::io   &w, int revents);
     ev::io2  io2 ; void io2_cb  (ev::io   &w, int revents);
     ev::idle idle; void idle_cb (ev::idle &w, int revents);

     myclass (int fd)
     {
       io  .set <myclass, &myclass::io_cb  > (this);
       io2 .set <myclass, &myclass::io2_cb > (this);
       idle.set <myclass, &myclass::idle_cb> (this);

       io.set (fd, ev::WRITE); // configure the watcher
       io.start ();            // start it whenever convenient

       io2.start (fd, ev::READ); // set + start in one call
     }
   };


I am wondering how to instantiate a loop in C++ and how to pass that loop to
the ev::io constructor. The documentation says ev::io(loop) but this is not
very helpful regarding the type of the object that needs to be passed to the
constructor.

Some body please help me.

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20101209/63190b91/attachment.html>


More information about the libev mailing list