similar to: [PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.

Displaying 20 results from an estimated 2000 matches similar to: "[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments."

2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
The definition of functions that take a callback is changed so that the callback and user_data are combined into a single structure, eg: int64_t nbd_aio_pread (struct nbd_handle *h, void *buf, size_t count, uint64_t offset, - int (*completion_callback) (/*..*/), void *user_data, + nbd_completion_callback completion_callback, uint32_t flags); Several
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
The freeing feature can now be done by associating a free callback with a closure's user_data, so having the valid_flag is no longer necessary and it can be completely removed. This mostly reverts commit 2d9b98e96772e282d51dafac07f16387dadc8afa. --- TODO | 2 - docs/libnbd.pod | 64 ++-------------- examples/glib-main-loop.c |
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
Previously closures had a crude flag which tells if they are persistent or transient. Transient closures (flag = false) last for the lifetime of the currently called libnbd function. Persistent closures had an indefinite lifetime which could last for as long as the handle. In language bindings handling persistent closures was wasteful as we needed to register a "close callback" to
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
Previously closures had a crude flag which tells if they are persistent or transient. Transient closures (flag = false) last for the lifetime of the currently called libnbd function. Persistent closures had an indefinite lifetime which could last for as long as the handle. In language bindings handling persistent closures was wasteful as we needed to register a "close callback" to
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
Previously closures had a crude flag which tells if they are persistent or transient. Transient closures (flag = false) last for the lifetime of the currently called libnbd function. Persistent closures had an indefinite lifetime which could last for as long as the handle. In language bindings handling persistent closures was wasteful as we needed to register a "close callback" to
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
Change the way that we deal with freeing closures in language bindings: * The valid_flag is removed (mostly reverting commit 2d9b98e96772e282d51dafac07f16387dadc8afa). * An extra ‘free’ parameter is added to all callback structures. This is called by the library whenever the closure won't be called again (so the user_data can be freed). This is analogous to valid_flag ==
2019 Jul 25
4
Re: [PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
On 7/25/19 8:07 AM, Richard W.M. Jones wrote: > Previously closures had a crude flag which tells if they are > persistent or transient. Transient closures (flag = false) last for > the lifetime of the currently called libnbd function. Persistent > closures had an indefinite lifetime which could last for as long as > the handle. In language bindings handling persistent closures
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
In preparation for closure lifetimes, split up the Closure so it no longer describes a list of closures, but a single callback. This changes the API because functions which take 2 or more closures now pass a separate user_data for each one. --- docs/libnbd.pod | 3 +- examples/strict-structured-reads.c | 2 +- generator/generator | 760
2019 Jul 16
1
[libnbd PATCH] generator: Prefer closure opaque after function pointer in C
Existing practice tends to prefer the void* closure argument for C callbacks to occur after the function pointer (POSIX: pthread_create; glibc: qsort_r; glib: g_thread_new; libvirt: virConnectDomainEventRegisterAny; etc.). It's also handy to think that calling 'myfunc(cb, arg)' will eventually result in a call to 'cb(arg)'. While I couldn't quickly find any style guide
2019 Aug 12
0
[PATCH libnbd 4/7] lib: Allow closure user_data to be associated with a free callback.
Mechanical change: Wherever we call any closure with the LIBNBD_CALLBACK_FREE function, we also call nbd_internal_free_callback with the closure's user_data. This allows calls to associate a free callback with any closure via its user_data pointer. --- generator/states-reply-simple.c | 1 + generator/states-reply-structured.c | 24 ++++++++++++++++++------ generator/states-reply.c
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
A Closure is a list of (usually one, but can be more) closures. In C there is also a singe ‘void *user_data’ parameter which is passed by the caller into the function and through as the first parameter of each callback invocation. By grouping the previously separate Opaque and Callback* parameters together we can avoid the awkward situation where we have to scan through the argument list to try
2020 Sep 07
0
[libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
We have a memory leak when a function with a closure exits early prior to registering that closure through some path that will guarantee cleanup. The easiest way to fix it is to guarantee that once a closure is passed into a public API, it will be cleaned regardless of whether that API succeeds or fails. But to avoid cleaning the closure more than once, we need to refactor our internal handling,
2019 Jul 30
3
[PATCH libnbd] lib: Remove cookie parameter from completion callbacks.
As discussed in this thread, the parameter is an invitation to write code with race conditions: https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00309 --- docs/libnbd.pod | 6 +- examples/glib-main-loop.c | 10 ++-- examples/strict-structured-reads.c | 2 +- generator/generator | 57
2019 Aug 14
1
Re: [PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
On 8/13/19 5:36 PM, Richard W.M. Jones wrote: > Change the way that we deal with freeing closures in language > bindings: > > * The valid_flag is removed (mostly reverting > commit 2d9b98e96772e282d51dafac07f16387dadc8afa). > > * An extra ‘free’ parameter is added to all callback structures. This > is called by the library whenever the closure won't be called
2019 Jul 24
0
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
On Wed, Jul 24, 2019 at 10:18:20AM -0500, Eric Blake wrote: > On 7/24/19 7:17 AM, Richard W.M. Jones wrote: > > +=head2 Callback lifetimes > > + > > +All callbacks have an C<int valid_flag> parameter which is used to > > +help with the lifetime of the callback. C<valid_flag> contains the > > +I<logical or> of: > > Again, worth mentioning
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
On 7/24/19 7:17 AM, Richard W.M. Jones wrote: > Previously closures had a crude flag which tells if they are > persistent or transient. Transient closures (flag = false) last for > the lifetime of the currently called libnbd function. Persistent > closures had an indefinite lifetime which could last for as long as > the handle. In language bindings handling persistent closures
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
On 7/24/19 7:17 AM, Richard W.M. Jones wrote: > Previously closures had a crude flag which tells if they are > persistent or transient. Transient closures (flag = false) last for > the lifetime of the currently called libnbd function. Persistent > closures had an indefinite lifetime which could last for as long as > the handle. In language bindings handling persistent closures
2019 Jul 16
1
Re: [PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
On 7/16/19 6:04 AM, Richard W.M. Jones wrote: > A Closure is a list of (usually one, but can be more) closures. In C > there is also a singe ‘void *user_data’ parameter which is passed by > the caller into the function and through as the first parameter of > each callback invocation. > > By grouping the previously separate Opaque and Callback* parameters > together we can
2019 Jul 24
1
Re: [PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
On 7/24/19 11:54 AM, Richard W.M. Jones wrote: > Previously closures had a crude flag which tells if they are > persistent or transient. Transient closures (flag = false) last for > the lifetime of the currently called libnbd function. Persistent > closures had an indefinite lifetime which could last for as long as > the handle. In language bindings handling persistent closures
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
We were previously generating one instance of the Python closure wrapper per (function * Closure arg). However these wrappers didn't actually differ across functions. We can therefore save a lot of code by only generating one wrapper per closure globally. This reduces the amount of generated code by nearly 25%. Before and after: $ wc -l python/methods.c 3275 python/methods.c $ wc -l