]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virthread: Add infrastructure for static virCond definitions
authorPeter Krempa <pkrempa@redhat.com>
Wed, 4 Jun 2025 19:59:12 +0000 (21:59 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 12 Jun 2025 08:17:03 +0000 (10:17 +0200)
Add the automatic cleanup handler as well as static initializer to allow
simple stack allocated conditions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virthread.h

index a7ec6bf32c5b5de8de608dc824632d219987fc1e..9e4e8cdafeb8d132a15be41ba1256c98bc00c9a5 100644 (file)
@@ -73,6 +73,11 @@ struct virOnceControl {
         .once = PTHREAD_ONCE_INIT \
     }
 
+#define VIR_COND_INITIALIZER \
+    { \
+        .cond = PTHREAD_COND_INITIALIZER \
+    }
+
 typedef void (*virOnceFunc)(void);
 
 typedef void (*virThreadFunc)(void *opaque);
@@ -142,6 +147,7 @@ void virRWLockUnlock(virRWLock *m);
 
 int virCondInit(virCond *c) G_GNUC_WARN_UNUSED_RESULT;
 int virCondDestroy(virCond *c);
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virCond, virCondDestroy);
 
 /* virCondWait, virCondWaitUntil:
  * These functions can return without the associated predicate