9147cc2c9dc7137bb03a48d1706693f4fddcb22d
[fio.git] / lib / tp.h
1 #ifndef FIO_TP_H
2 #define FIO_TP_H
3
4 #include "../flist.h"
5
6 struct tp_work;
7 typedef int (tp_work_fn)(struct tp_work *);
8
9 struct tp_work {
10         struct flist_head list;
11         tp_work_fn *fn;
12         int wait;
13         int prio;
14         pthread_cond_t cv;
15         pthread_mutex_t lock;
16         volatile int done;
17 };
18
19 struct tp_data {
20         pthread_t thread;
21         pthread_cond_t cv;
22         pthread_mutex_t lock;
23         struct flist_head work;
24         volatile int thread_exit;
25         pthread_cond_t sleep_cv;
26         volatile int sleeping;
27 };
28
29 extern void tp_init(struct tp_data **);
30 extern void tp_exit(struct tp_data **);
31 extern void tp_queue_work(struct tp_data *, struct tp_work *);
32
33 #endif