summaryrefslogtreecommitdiff
path: root/src/threadpool.h
blob: c28f03a1a6337169b6be063c931ae117d644c2d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef __VXGG_REWRITE___THREADPOOL_H___13601325413136___
#define __VXGG_REWRITE___THREADPOOL_H___13601325413136___

#include <threads.h>

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);
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