• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-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 PLATFORM_QUEUE_H
10 #define PLATFORM_QUEUE_H
11 
12 #include "hdf_dlist.h"
13 #include "osal_thread.h"
14 #include "osal_sem.h"
15 #include "osal_spinlock.h"
16 
17 #ifdef __cplusplus
18 #if __cplusplus
19 extern "C" {
20 #endif
21 #endif /* __cplusplus */
22 
23 struct PlatformMsg;
24 struct PlatformQueue;
25 
26 struct PlatformMsg {
27     struct DListHead node;
28     int32_t code;
29     int32_t error;
30     void *data;
31 };
32 
33 typedef int32_t (*PlatformMsgHandle)(struct PlatformQueue *queue, struct PlatformMsg *msg);
34 
35 struct PlatformQueue {
36     const char *name;
37     OsalSpinlock spin;
38     bool start;
39     struct OsalSem sem;
40     struct DListHead msgs;
41     struct OsalThread thread; /* the worker thread of this queue */
42     PlatformMsgHandle handle;
43     void *data;
44 };
45 
46 int32_t PlatformQueueAddMsg(struct PlatformQueue *queue, struct PlatformMsg *msg);
47 struct PlatformQueue *PlatformQueueCreate(PlatformMsgHandle handle, const char *name, void *data);
48 void PlatformQueueDestroy(struct PlatformQueue *queue);
49 int32_t PlatformQueueStart(struct PlatformQueue *queue);
50 
51 #ifdef __cplusplus
52 #if __cplusplus
53 }
54 #endif
55 #endif /* __cplusplus */
56 
57 #endif /* PLATFORM_QUEUE_H */
58