On Fri, Jul 04, 2014 at 12:14:06PM +0100, Richard W.M. Jones wrote:
On Tue, Jul 01, 2014 at 09:35:21AM +0100, Daniel P. Berrange wrote:
> For the async API design, I could see two potential designs
>
> 1. A custom callback to run per API
>
> typedef (void)(*virDomainBlockInfoCallback)(virDomainPtr dom,
> bool isError,
> virDomainBlockInfoPtr info,
> void *opaque);
>
> int virDomainGetBlockInfoAsync(virDomainPtr dom,
> const char *disk,
> virDomainBlockInfoCallback cb,
> void *opaque,
> unsigned int flags);
>
>
> 2. A standard callback and a pair of APIs
>
> typedef void *virDomainAsyncResult;
> typedef (void)(*virDomainAsyncCallback)(virDomainPtr dom,
> virDomainAsyncResult res);
>
> void virDomainGetBlockInfoAsync(virDomainPtr dom,
> const char *disk,
> virDomainBlockInfoCallback cb,
> void *opaque,
> unsigned int flags);
> int virDomainGetBlockInfoFinish(virDomainPtr dom,
> virDomainAsyncResult res,
> virDomainBlockInfoPtr info);
Could we consider an API which worked across all active domains?
Of course. I was intentionally ignoring the "bulk API" side of the
request in this example, to just focus on the illustration of some
general patterns for providing an async API design.
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|