<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi all,<div><br></div><div>I’m trying to integrate Perl’s Sys::Virt into an already existing AnyEvent program.</div><div><br></div><div>I’m accustomed to writing things like this:</div><div><br></div><div><div style="font-family: Menlo-Regular;"><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div>use EV;</div><div>use AnyEvent;</div><div>use AnyEvent::Handle;</div></blockquote></div><blockquote style="font-family: Menlo-Regular; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div>my $h = AnyEvent::Handle->new(fh => $fh, …);</div><div>$h->on_read(sub { … });</div><div><br></div><div>EV::run;  ## start the event loop</div></blockquote><font face="Menlo-Regular"><br></font></div><div><div style="font-family: Menlo-Regular;">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().</div><div style="font-family: Menlo-Regular;"><br></div><div style="font-family: Menlo-Regular;">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?</div><div style="font-family: Menlo-Regular;"><br></div><div style="font-family: Menlo-Regular;">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.</div><div style="font-family: Menlo-Regular;"><br></div><div style="font-family: Menlo-Regular;">I’d appreciate any advice you may have—thanks!</div></div><div style="font-family: Menlo-Regular;"><br></div><div style="font-family: Menlo-Regular;">Scott</div></body></html>