1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDF_TASK_QUEUE_H
10 #define HDF_TASK_QUEUE_H
11 
12 #include "hdf_dlist.h"
13 #include "osal_sem.h"
14 #include "osal_mutex.h"
15 #include "osal_thread.h"
16 
17 struct HdfTaskType;
18 typedef int32_t (*HdfTaskFunc)(struct HdfTaskType *para);
19 
20 struct HdfTaskType {
21     struct DListHead node;
22     HdfTaskFunc func;
23 };
24 
25 struct HdfTaskQueue {
26     struct OsalSem sem;
27     struct OsalMutex mutex;
28     struct DListHead head;
29     struct OsalThread thread;
30     bool threadRunFlag;
31     HdfTaskFunc queueFunc;
32     const char *queueName;
33 };
34 
35 void HdfTaskEnqueue(struct HdfTaskQueue *queue, struct HdfTaskType *task);
36 struct HdfTaskQueue *HdfTaskQueueCreate(HdfTaskFunc func, const char *name);
37 void HdfTaskQueueDestroy(struct HdfTaskQueue *queue);
38 
39 #endif /* HDF_TASK_QUEUE_H */
40