[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [libnbd] More thoughts on callbacks and more



On 7/22/19 9:25 AM, Richard W.M. Jones wrote:
> This has an annoying subtlety around the fact that we can pass a
> single user_data and multiple closures in one function call.
> 
> The LIBNBD_CALLBACK_FREE function would be called several times with
> the same user_data in this case, which means the callback must do some
> kind of reference counting before the user_data can be freed.
> 
> I propose that we split up Closure so it describes a single closure,
> although that does mean that separate user_data must be passed with
> each function pointer (which may not be a bad thing).

Indeed, and it is a bit more API churn (nbd_aio_pread_structured_allback
and nbd_aio_block_status_callback would now take two void* user_data
parameters, which means they must have different parameter names: maybe
extent_user_data vs. callback_user_data), but it makes sense.  But it
also simplifies 'Closure' in the generator, as you no longer have an
array of callback functions that share a common data.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]