summaryrefslogtreecommitdiff
path: root/wg.h
diff options
context:
space:
mode:
Diffstat (limited to 'wg.h')
-rw-r--r--wg.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/wg.h b/wg.h
new file mode 100644
index 0000000..777e8a3
--- /dev/null
+++ b/wg.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <pthread.h>
+
+/* Thread management tools modeled on https://golang.org/pkg/sync/#WaitGroup */
+
+/* pthread_cond_t is overly complicated. Just use a self-pipe. */
+
+struct wg {
+ int count;
+ pthread_mutex_t lock;
+ int fd_wait;
+ int fd_signal;
+};
+
+void wg_init(struct wg *);
+void wg_add(struct wg *, unsigned int);
+void wg_sub(struct wg *, unsigned int);
+void wg_wait(struct wg*);