aboutsummaryrefslogtreecommitdiff
path: root/src/threading/pool.h
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-08-30 22:55:26 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-08-30 22:55:26 +0200
commit37c4373dce60b31ccc0100d85d0013aef82809e7 (patch)
tree5779a0f437ea1a88b91a4a9e6a3c879d216c9d50 /src/threading/pool.h
parent91f695797fac3e1c2d20bea70f8c877d7df03b68 (diff)
downloadOFQT-37c4373dce60b31ccc0100d85d0013aef82809e7.tar.gz
OFQT-37c4373dce60b31ccc0100d85d0013aef82809e7.zip
implement thread pools
Diffstat (limited to 'src/threading/pool.h')
-rw-r--r--src/threading/pool.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/threading/pool.h b/src/threading/pool.h
new file mode 100644
index 0000000..73655d0
--- /dev/null
+++ b/src/threading/pool.h
@@ -0,0 +1,38 @@
+#ifndef POOL_H
+#define POOL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+
+typedef void *(*worker_func)(void *);
+
+struct pool_task_t {
+ worker_func func;
+ void* arg;
+ int done;
+};
+
+struct pool_t {
+ int workers;
+
+ struct pool_task_t* tasks;
+ struct pool_task_t* task_next;
+ size_t pool_size;
+
+ int* condition;
+};
+
+struct pool_t* pool_init();
+void pool_free(struct pool_t*);
+
+void pool_submit(struct pool_t*, worker_func, void*);
+void pool_complete(struct pool_t*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif \ No newline at end of file