From 0ee5044805c8d157d5023fc1322f980e3a480df7 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Tue, 22 Apr 2025 16:35:44 -0500 Subject: Start work on threadpool implementation --- src/threadpool.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/threadpool.h') diff --git a/src/threadpool.h b/src/threadpool.h index 8e3ee41..c28f03a 100644 --- a/src/threadpool.h +++ b/src/threadpool.h @@ -3,6 +3,25 @@ #include +typedef int (*task_callback)(void*); +typedef struct task task; +typedef struct cq cqueue; +typedef struct tp threadpool; + +task * task_init(task_callback cb, void *arg); +void task_free(task *ts); + +cqueue * cqueue_init(int mtx_type); +void cqueue_free(cqueue *cq); +int cqueue_append(cqueue * const cq, task *tsk); +int cqueue_prepend(cqueue * const cq, task *tsk); +int cqueue_insert(cqueue * const cq, task *tsk, int index); +int cqueue_size(cqueue const * const cq); +int cqueue_isempty(cqueue const * const cq); +int cqueue_trypop(cqueue * const cq, task **ret); +int cqueue_waitpop(cqueue * const cq, task **ret); +int cqueue_cancel(cqueue * const cq); + typedef struct mtxp mtxpair; mtxpair * mtxpair_init(void * const data, int type); void mtxpair_free(mtxpair *mp); @@ -10,4 +29,6 @@ int mtxpair_setdata(mtxpair * const mp, void * const data); int thrd_createwmx(thrd_t * const thr, thrd_start_t func, mtxpair * const mtxd); +int cqueue_cancel(cqueue * const cq); + #endif \ No newline at end of file -- cgit v1.2.3