6 struct workqueue_work {
7 struct flist_head list;
10 typedef void (workqueue_work_fn)(struct thread_data *, struct workqueue_work *);
11 typedef bool (workqueue_pre_sleep_flush_fn)(struct thread_data *);
12 typedef void (workqueue_pre_sleep_fn)(struct thread_data *);
14 struct workqueue_ops {
15 workqueue_work_fn *fn;
16 workqueue_pre_sleep_flush_fn *pre_sleep_flush_fn;
17 workqueue_pre_sleep_fn *pre_sleep_fn;
21 unsigned int max_workers;
23 struct thread_data *td;
24 struct workqueue_ops ops;
27 struct submit_worker *workers;
28 unsigned int next_free_worker;
30 pthread_cond_t flush_cond;
31 pthread_mutex_t flush_lock;
32 pthread_mutex_t stat_lock;
33 volatile int wake_idle;
36 int workqueue_init(struct thread_data *td, struct workqueue *wq, struct workqueue_ops *ops, unsigned int max_workers);
37 void workqueue_exit(struct workqueue *wq);
39 bool workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work);
40 void workqueue_flush(struct workqueue *wq);
42 static inline bool workqueue_pre_sleep_check(struct workqueue *wq)
44 if (!wq->ops.pre_sleep_flush_fn)
47 return wq->ops.pre_sleep_flush_fn(wq->td);
50 static inline void workqueue_pre_sleep(struct workqueue *wq)
52 if (wq->ops.pre_sleep_fn)
53 wq->ops.pre_sleep_fn(wq->td);