1Sys::Virt::EventImpl(3pUms)er Contributed Perl DocumentatSiyosn::Virt::EventImpl(3pm)
2
3
4

NAME

6       Sys::Virt::EventImpl - Event loop implementation parent class
7

DESCRIPTION

9       The "Sys::Virt::EventImpl" module represents the contract for
10       integrating libvirt with an event loop. This package is abstract and
11       intended to be subclassed to provide an actual implementation.
12
13       This module is new in 9.5.0. To use this module while also supporting
14       pre-9.5.0 versions, could may consider the code below to set up
15       inheritance.
16
17         package YourImpl;
18
19         use strict;
20         use warnings;
21
22         BEGIN {
23           if (require Sys::Virt::EventImpl) {
24              eval "use parent 'Sys::Virt::EventImpl';";
25           }
26           else {
27              eval "use parent 'Sys::Virt::Event';";
28           }
29         }
30

EVENT LOOP IMPLEMENTATION

32       When implementing an event loop, the implementation must be a sub-class
33       of the "Sys::Virt::EventImpl" class.  It must override these functions:
34
35       my $watch_id = $self->add_handle( $fd, $events, $callback, $opaque, $ff
36       )
37           Registers $callback to be invoked for $events on $fd. Use
38           "_run_handle_callback" to do the actual invocation from the event
39           loop (see "Callback helpers" below).
40
41           Next to the events explicitly indicated by $events,
42           "Sys::Virt::Event::HANDLE_ERROR" and
43           "Sys::Virt::Event::HANDLE_HANGUP" should always trigger the
44           callback.
45
46           Returns a positive integer $watch_id or -1 on error.
47
48       $self->update_handle($watch_id, $events)
49           Replaces the events currencly triggering $watch_id with $events.
50
51       my $ret = $self->remove_handle($watch_id)
52           Removes the $callback from the $fd.
53
54           Returns 0 on success or -1 on failure.
55
56           IMPORTANT This should also make sure that "_free_callback_opaque"
57           is called after this function has been executed: not doing so will
58           prevent the connection from being garbage collected.
59
60       my $timer_id = $self->add_timeout($frequency, $callback, $opaque, $ff)
61       $self->update_timeout($timer_id, $frequency)
62           Replaces the interval on the timer with $frequency.
63
64       my $ret = $self->remove_timeout($timer_id)
65           Discards the timer.
66
67           Returns 0 on success or -1 on failure.
68
69           IMPORTANT This should also make sure that "_free_callback_opaque"
70           is called after this function has been executed: not doing so will
71           prevent the connection from being garbage collected.
72
73   Callback helpers
74       $self->_run_handle_callback($watch_id, $fd, $events, $cb, $opaque)
75           A helper method for executing a callback in response to one of more
76           $events on the file handle $fd. The $watch number is the unique
77           identifier associated with the file descriptor. The $cb and $opaque
78           parameters are the callback and data registered for the handle.
79
80       $self->_run_timeout_callback($timer_id, $cb, $opaque)
81           A helper method for executing a callback in response to the expiry
82           of a timeout identified by $timer. The $cb and $opaque parameters
83           are the callback and data registered for the timeout.
84
85       $self->_free_callback_opaque($ff, $opaque)
86           A helper method for freeing the data associated with a callback.
87           The $ff and $opaque parameters are the callback and data registered
88           for the handle/timeout.
89
90           IMPORTANT This helper must be called outside of any callbacks; that
91           is after the "remove_handle" or "remove_timeout" callbacks
92           complete.
93

AUTHORS

95       Daniel P. Berrange <berrange@redhat.com>
96
98       Copyright (C) 2006-2009 Red Hat Copyright (C) 2006-2009 Daniel P.
99       Berrange
100

LICENSE

102       This program is free software; you can redistribute it and/or modify it
103       under the terms of either the GNU General Public License as published
104       by the Free Software Foundation (either version 2 of the License, or at
105       your option any later version), or, the Artistic License, as specified
106       in the Perl README file.
107

SEE ALSO

109       Sys::Virt,  "http://libvirt.org"
110
111
112
113perl v5.38.0                      2023-09-08         Sys::Virt::EventImpl(3pm)
Impressum