summary refs log tree commit diff stats
path: root/include/qemu/thread.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-12-02 12:05:45 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2015-01-13 13:43:29 +0000
commitef57137f1b30545a477ab798d34a669b0abf5320 (patch)
tree72fbda74c56d638e7ee78c0e21d8053219d385f0 /include/qemu/thread.h
parentd1d1b206b07977fe0e75b0254e5b50c215c97803 (diff)
downloadfocaccia-qemu-ef57137f1b30545a477ab798d34a669b0abf5320.tar.gz
focaccia-qemu-ef57137f1b30545a477ab798d34a669b0abf5320.zip
qemu-thread: add per-thread atexit functions
Destructors are the main additional feature of pthread TLS compared
to __thread.  If we were using C++ (hint, hint!) we could have used
thread-local objects with a destructor.  Since we are not, instead,
we add a simple Notifier-based API.

Note that the notifier must be per-thread as well.  We can add a
global list as well later, perhaps.

The Win32 implementation has some complications because a) detached
threads used not to have a QemuThreadData; b) the main thread does
not go through win32_start_routine, so we have to use atexit too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 1417518350-6167-3-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'include/qemu/thread.h')
-rw-r--r--include/qemu/thread.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index f7e3b9b290..e89fdc9785 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -61,4 +61,8 @@ bool qemu_thread_is_self(QemuThread *thread);
 void qemu_thread_exit(void *retval);
 void qemu_thread_naming(bool enable);
 
+struct Notifier;
+void qemu_thread_atexit_add(struct Notifier *notifier);
+void qemu_thread_atexit_remove(struct Notifier *notifier);
+
 #endif