]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libfrog/workqueue.h
libfrog: fix bitmap error communication problems
[thirdparty/xfsprogs-dev.git] / libfrog / workqueue.h
CommitLineData
959ef981 1// SPDX-License-Identifier: GPL-2.0+
f434fd95
DW
2/*
3 * Copyright (C) 2017 Oracle. All Rights Reserved.
f434fd95 4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
f434fd95 5 */
56598728
DW
6#ifndef __LIBFROG_WORKQUEUE_H__
7#define __LIBFROG_WORKQUEUE_H__
f434fd95 8
40b2e298
BS
9#include <pthread.h>
10
f434fd95
DW
11struct workqueue;
12
13typedef void workqueue_func_t(struct workqueue *wq, uint32_t index, void *arg);
14
15struct workqueue_item {
16 struct workqueue *queue;
17 struct workqueue_item *next;
18 workqueue_func_t *function;
19 void *arg;
20 uint32_t index;
21};
22
23struct workqueue {
24 void *wq_ctx;
25 pthread_t *threads;
26 struct workqueue_item *next_item;
27 struct workqueue_item *last_item;
28 pthread_mutex_t lock;
29 pthread_cond_t wakeup;
30 unsigned int item_count;
31 unsigned int thread_count;
32 bool terminate;
71296cf8 33 bool terminated;
f434fd95
DW
34};
35
36int workqueue_create(struct workqueue *wq, void *wq_ctx,
37 unsigned int nr_workers);
38int workqueue_add(struct workqueue *wq, workqueue_func_t fn,
39 uint32_t index, void *arg);
71296cf8 40int workqueue_terminate(struct workqueue *wq);
f434fd95
DW
41void workqueue_destroy(struct workqueue *wq);
42
56598728 43#endif /* __LIBFROG_WORKQUEUE_H__ */