C++ How TO?

Marc Lehmann schmorp at schmorp.de
Thu Dec 9 11:04:40 CET 2010


On Thu, Dec 09, 2010 at 02:58:55PM +0530, Praveen Baratam <praveen.baratam+libev at gmail.com> wrote:
> There are very examples related to C++ binding.

[few?]

> I am wondering how to instantiate a loop in C++ and how to pass that loop to

Juse use the documented API, C++ didn't remove functions and pointers from
the language :)

instantiate:

  struct ev_loop *loop = ev_loop (0);

you pass that loop ro the ev::io constructor by using one of the documented
ways to do that:

  constructor: ev_io my_io (loop);
  using set:   my_io.set (loop);

Passing tp to the constructor is preferable, as otherwise you will have a
temporary binding to the default loop.

You can also use the rest of the documented API in C++, the watcher
classes are just added sugar, they are not required to use libev.

As for the undocumented loop classes, these are undocumented for a reason
(they have never been finished, or even tested). You are invited to use
them if you wish, but if it breaks, it's yours to keep :)

-- 
                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