Sys::Virt::Event integration w/ AnyEvent

Marc Lehmann schmorp at schmorp.de
Sat Mar 15 09:56:41 CET 2014


On Fri, Mar 14, 2014 at 05:40:24PM -0600, Scott Wiersdorf <scott at betterservers.com> wrote:
> I’ve looked carefully at all of the included AnyEvent::Impl::* libraries, per the "SUPPLYING YOUR OWN EVENT MODEL INTERFACE" documentation in AnyEvent.pm and just don’t see how the two overlap. Sys::Virt::Event supplies a run_default() method that runs a single iteration of its loop. I’ve been able to hack something like this:

Ah, it's atcually better, apparently libvirt supports event loop
intergration (similar to AnyEvent), so no AnyEvent implementation or glue
or magic is needed.

Instead, you provider your own SysVirtEvent implementation for AnyEvent:

   package My::SysVirtEvent::Impl;

   use Sys::Virt::Event;
   use AnyEvent;
   
   Sys::Virt::Event::register __PACKAGE__;

   sub _run_timeout_callback {
      my ($timer, $cb, $data) = @_;

      # do the thing, I am not sure what
   }

   sub _run_handle_callback {
      my ($watch, $fd, $events, $cb, $data) = @_;
      ...
   }

   sub _free_callback_opaque {
      my ($cb, $data) = @_; # whatt he fuck, callback????
      ...
   }

   1;

Inside, you can use EV or AnyEvent.

I have many questions that the documentation doesn't answer, for
example, whats the first argument to _free_callback_opaque, whats
Sys::Virt::Event::HANDLE_HANGUP and when should it be generated, and why
are the Sys::Virt::Event::XXX functions even there (the documentation says
I need to provide these by subclassing, but you cannot provide functions
by subclassing).

Likely, you need to look at the source code of Sys::Virt to see what this
module is really supposed to do, and how to use it, as the documentation
is completely lacking.

Then you could write your own interface to either EV or AnyEvent (the
latter is more flexible, but can't implement anything like run_default, but
the documentation doesn't say how run_default is implemented either).

Then anybody could use your module to get Sys::Virt working on top of
AnyEvent, as an AnyEvent user, and then you can use any underlying event
loop, e.g. Gtk2. In fact, it would be a good module to provide with
Sys::Virt.

You don't need to know any AnyEvent internals, or how to integrate it with
other event loops, as the goal would be to integrate Sys::Virt with AnyEvebt,
and not vice versa.

I cannot provide any Sys::Virt help, which is all that is needed - you
need to figure out how this Sys::Virt::Event thing is supposed to work by
loking at the sources or asking the Sys::Virt developers.

-- 
                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 anyevent mailing list