diff options
| author | @syxhe <https://t.me/syxhe> | 2025-04-22 16:35:44 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-04-22 16:35:44 -0500 |
| commit | 0ee5044805c8d157d5023fc1322f980e3a480df7 (patch) | |
| tree | 0cbdcbb5286a3c776c12d490afb1e24c40771294 /src/threadpool.h | |
| parent | c704a8a382c231e066a7fbf0402a33455c40b8f5 (diff) | |
Start work on threadpool implementation
Diffstat (limited to 'src/threadpool.h')
| -rw-r--r-- | src/threadpool.h | 21 |
1 files changed, 21 insertions, 0 deletions
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 @@ | |||
| 3 | 3 | ||
| 4 | #include <threads.h> | 4 | #include <threads.h> |
| 5 | 5 | ||
| 6 | typedef int (*task_callback)(void*); | ||
| 7 | typedef struct task task; | ||
| 8 | typedef struct cq cqueue; | ||
| 9 | typedef struct tp threadpool; | ||
| 10 | |||
| 11 | task * task_init(task_callback cb, void *arg); | ||
| 12 | void task_free(task *ts); | ||
| 13 | |||
| 14 | cqueue * cqueue_init(int mtx_type); | ||
| 15 | void cqueue_free(cqueue *cq); | ||
| 16 | int cqueue_append(cqueue * const cq, task *tsk); | ||
| 17 | int cqueue_prepend(cqueue * const cq, task *tsk); | ||
| 18 | int cqueue_insert(cqueue * const cq, task *tsk, int index); | ||
| 19 | int cqueue_size(cqueue const * const cq); | ||
| 20 | int cqueue_isempty(cqueue const * const cq); | ||
| 21 | int cqueue_trypop(cqueue * const cq, task **ret); | ||
| 22 | int cqueue_waitpop(cqueue * const cq, task **ret); | ||
| 23 | int cqueue_cancel(cqueue * const cq); | ||
| 24 | |||
| 6 | typedef struct mtxp mtxpair; | 25 | typedef struct mtxp mtxpair; |
| 7 | mtxpair * mtxpair_init(void * const data, int type); | 26 | mtxpair * mtxpair_init(void * const data, int type); |
| 8 | void mtxpair_free(mtxpair *mp); | 27 | void mtxpair_free(mtxpair *mp); |
| @@ -10,4 +29,6 @@ int mtxpair_setdata(mtxpair * const mp, void * const data); | |||
| 10 | 29 | ||
| 11 | int thrd_createwmx(thrd_t * const thr, thrd_start_t func, mtxpair * const mtxd); | 30 | int thrd_createwmx(thrd_t * const thr, thrd_start_t func, mtxpair * const mtxd); |
| 12 | 31 | ||
| 32 | int cqueue_cancel(cqueue * const cq); | ||
| 33 | |||
| 13 | #endif \ No newline at end of file | 34 | #endif \ No newline at end of file |
