diff mbox series

[for-3.1,1/2] include/qemu/thread.h: Document qemu_thread_atexit* API

Message ID 20181105135538.28025-2-peter.maydell@linaro.org
State New
Headers show
Series Fix qemu_thread_atexit* for OSX | expand

Commit Message

Peter Maydell Nov. 5, 2018, 1:55 p.m. UTC
Add documentation for the qemu_thread_atexit_add() and
qemu_thread_atexit_remove() functions.

We include a (previously undocumented) constraint that notifiers
may not be called if a thread is exiting because the entire
process is exiting. This is fine for our current use because
the callers use it only for cleaning up resources which go away
on process exit (memory, Win32 fibers), and we will need the
flexibility for the new posix implementation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/thread.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Eric Blake Nov. 5, 2018, 4:04 p.m. UTC | #1
On 11/5/18 7:55 AM, Peter Maydell wrote:
> Add documentation for the qemu_thread_atexit_add() and
> qemu_thread_atexit_remove() functions.
> 
> We include a (previously undocumented) constraint that notifiers
> may not be called if a thread is exiting because the entire
> process is exiting. This is fine for our current use because
> the callers use it only for cleaning up resources which go away
> on process exit (memory, Win32 fibers), and we will need the
> flexibility for the new posix implementation.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/qemu/thread.h | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index b2661b66720..55d83a907cd 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -162,7 +162,29 @@  void qemu_thread_exit(void *retval);
 void qemu_thread_naming(bool enable);
 
 struct Notifier;
+/**
+ * qemu_thread_atexit_add:
+ * @notifier: Notifier to add
+ *
+ * Add the specified notifier to a list which will be run via
+ * notifier_list_notify() when this thread exits (either by calling
+ * qemu_thread_exit() or by returning from its start_routine).
+ * The usual usage is that the caller passes a Notifier which is
+ * a per-thread variable; it can then use the callback to free
+ * other per-thread data.
+ *
+ * If the thread exits as part of the entire process exiting,
+ * it is unspecified whether notifiers are called or not.
+ */
 void qemu_thread_atexit_add(struct Notifier *notifier);
+/**
+ * qemu_thread_atexit_remove:
+ * @notifier: Notifier to remove
+ *
+ * Remove the specified notifier from the thread-exit notification
+ * list. It is not valid to try to remove a notifier which is not
+ * on the list.
+ */
 void qemu_thread_atexit_remove(struct Notifier *notifier);
 
 struct QemuSpin {