From 49839c88a98d3798f7b18c58f54f26f36cacff38 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Fri, 9 Dec 2022 16:46:49 +0800 Subject: Implement a simple thread pool and refactor Refactor --- tpool.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tpool.h (limited to 'tpool.h') diff --git a/tpool.h b/tpool.h new file mode 100644 index 0000000..e1079ef --- /dev/null +++ b/tpool.h @@ -0,0 +1,20 @@ +#include +#include + +#ifndef __TPOOL_H +#define __TPOOL_H + +struct tpool; +typedef struct tpool tpool_t; + +extern tpool_t *tpool; + +typedef void (*thread_func_t)(void *arg); + +tpool_t *tpool_create(size_t num); +void tpool_destroy(tpool_t *tp); + +bool tpool_add_work(tpool_t *tp, thread_func_t func, void *arg); +void tpool_wait(tpool_t *tp); + +#endif -- cgit v1.2.3