workqueue: add a workqueue_work type
[fio.git] / workqueue.h
... / ...
CommitLineData
1#ifndef FIO_RATE_H
2#define FIO_RATE_H
3
4#include "flist.h"
5
6struct workqueue_work {
7 struct flist_head list;
8};
9
10typedef void (workqueue_fn)(struct thread_data *, struct workqueue_work *);
11
12struct workqueue {
13 unsigned int max_workers;
14
15 struct thread_data *td;
16 workqueue_fn *fn;
17
18 uint64_t work_seq;
19 struct submit_worker *workers;
20 unsigned int next_free_worker;
21
22 pthread_cond_t flush_cond;
23 pthread_mutex_t flush_lock;
24 pthread_mutex_t stat_lock;
25 volatile int wake_idle;
26};
27
28int workqueue_init(struct thread_data *td, struct workqueue *wq, workqueue_fn *fn, unsigned int max_workers);
29void workqueue_exit(struct workqueue *wq);
30
31bool workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work);
32void workqueue_flush(struct workqueue *wq);
33
34#endif