Re: [PATCH v5 04/10] libxl: convert libxl_device_disk_add to an asyn op

Ian Jackson
Thu, 07 Jun 2012 16:47:04 -0000

Roger Pau Monne writes ("Re: [PATCH v5 04/10] libxl: convert
libxl_device_disk_add to an asyn op"):
> Can''t we remove _init, if it''s not needed? Having and
_init function
> makes people thing they have to use it, and the comments doesn''t
say
> anything about _wait calling _init itself.

_init is needed to provide a way to initialise the structure so that
it is safe to pass to _cancel.  This means that caller can use
idempotent initialisation and cleanup, which avoids leaks and logic
errors.

This is the same way it''s done for many other of the event functions,
eg:
    libxl__ev_FOO_{init,register,deregister}
    libxl__datacopier_{state,init,start,kill}
    libxl__bootloader_{state,init,run}

Feel free to provide a comment clarifying the API.

Ian.