Skip to content

Commit 258f61b

Browse files
committed
virthread: Add infrastructure for static virCond definitions
Add the automatic cleanup handler as well as static initializer to allow simple stack allocated conditions. Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Ján Tomko <[email protected]>
1 parent 6e44bb7 commit 258f61b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util/virthread.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ struct virOnceControl {
7373
.once = PTHREAD_ONCE_INIT \
7474
}
7575

76+
#define VIR_COND_INITIALIZER \
77+
{ \
78+
.cond = PTHREAD_COND_INITIALIZER \
79+
}
80+
7681
typedef void (*virOnceFunc)(void);
7782

7883
typedef void (*virThreadFunc)(void *opaque);
@@ -142,6 +147,7 @@ void virRWLockUnlock(virRWLock *m);
142147

143148
int virCondInit(virCond *c) G_GNUC_WARN_UNUSED_RESULT;
144149
int virCondDestroy(virCond *c);
150+
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virCond, virCondDestroy);
145151

146152
/* virCondWait, virCondWaitUntil:
147153
* These functions can return without the associated predicate

0 commit comments

Comments
 (0)