Hi all,

I’m trying to integrate Perl’s Sys::Virt into an already existing AnyEvent 
program.

I’m accustomed to writing things like this:

use EV;
use AnyEvent;
use AnyEvent::Handle;
my $h = AnyEvent::Handle->new(fh => $fh, …);
$h->on_read(sub { … });

EV::run;  ## start the event loop

I can add some code in the on_read() handler and every time the $fh has 
something to read, it will fire off. I’d like to do something similar with 
Sys::Virt, but I can’t seem to wrap my head around its event system. The only 
examples I can find are the ones included in Sys::Virt source, which consist of 
a series of run_once() calls, or a while loop around run_default().

Does anyone have any idea how I can make this play nicely with an existing 
event loop such as EV, or even to fire off ($cv->send) an AnyEvent condvar when 
the event I set in domain_event_register_any() triggers?

Our current solution involves setting an AnyEvent->timer, which periodically 
fires off and then does a run_once() to see if any events happened during the 
period, but we’d like something more responsive (i.e., triggers when the event 
actually occurs) and less poll-y feeling.

I’d appreciate any advice you may have—thanks!

Scott

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
libvirt-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvirt-users

Reply via email to