
On 03/19/2010 09:38 AM, Daniel P. Berrange wrote:
Since different event types can received different data in the callback, the API is defined with a generic callback. Specific events will each have a custom signature for their callback. Thus when registering an event it is neccessary to cast the callback to the generic signature
+/* A generic callback definition. Specific events usually have a customization + * with extra parameters */ +typedef void (*virConnectDomainEventGenericCallback)(virConnectPtr conn, + virDomainPtr dom, + void *opaque);
Should the callback be allowed to return anything, as void*? For example, I've seen some programming paradigms where you can write a generic iterator that marches through callbacks for each item in a set, allowing an early abort of the iteration if any of the callbacks return a non-NULL value (useful for both finding the first element that matches a given criteria, and for gracefully aborting operations on first failure).
+ +/** + * virConnectDomainEventRegister: + * @conn: pointer to the connection + * @dom: pointer to the domain + * @eventID: the event type to receive + * @cb: callback to the function handling domain events + * @opaque: opaque data to pass on to the callback + * @freecb: optional function to deallocate opaque when not used anymore + * + * Adds a callback to receive notifications of arbitrary domain events + * occurring on a domain. + * + * If dom is NULL, then events will be monitored for any domain. If dom + * is non-NULL, then only the specific domain will be monitored + * + * Most types of event have a callback providing a custom set of parameters + * for the event. When registering an event, it is thus neccessary to use
s/neccessary/necessary/ -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org