• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *   Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: OS Abstract Layer.
15  */
16 
17 /**
18  * @defgroup osal_workqueue osal_workqueue
19  */
20 #ifndef __OSAL_WORKQUEUE_H__
21 #define __OSAL_WORKQUEUE_H__
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 typedef struct osal_workqueue_ {
30     int queue_flag;
31     void *work;
32     void (*handler)(struct osal_workqueue_ *workqueue);
33 } osal_workqueue;
34 typedef void (*osal_workqueue_handler)(osal_workqueue *workqueue);
35 
36 /**
37  * @ingroup osal_workqueue
38  * @brief This API is used to initialization of workqueue.
39  *
40  * @par Description:
41  * This API is used to initialization of workqueue.
42  *
43  * @param work [in/out] the workqueue to be initialized.
44  * @param handler [in/out] the workqueue callback handler function.
45  *
46  * @par Support System:
47  * linux liteos freertos.
48  */
49 int osal_workqueue_init(osal_workqueue *work, osal_workqueue_handler handler);
50 
51 /**
52  * @ingroup osal_workqueue
53  * @brief put work task in global workqueue.
54  *
55  * @par Description:
56  * put work task in global workqueue.
57  * This puts a job in the kernel-global workqueue if it was not already queued and leaves it in
58  * the same position on the kernel-global workqueue otherwise.
59  *
60  * @param work [in] Job to be done.
61  * @return True/False
62  * @par Support System:
63  * linux liteos freertos.
64  */
65 int osal_workqueue_schedule(osal_workqueue *work);
66 
67 /**
68  * @ingroup osal_workqueue
69  * @brief This API is used to destroy workqueue.
70  *
71  * @par Description:
72  * This API is used to destroy workqueue.
73  *
74  * @param work [in] The work to be destroyed.
75  *
76  * @attention this api may free memory, work should be from osal_workqueue_init.
77  *
78  * @par Support System:
79  * linux liteos freertos.
80  */
81 void osal_workqueue_destroy(osal_workqueue *work);
82 
83 /**
84  * @ingroup osal_workqueue
85  * @brief wait for a work to finish executing the last queueing instance.
86  *
87  * @par Description:
88  * wait for a work to finish executing the last queueing instance.
89  * Wait until work has finished execution.
90  * work is guaranteed to be idle on return if it hasn't been requeued since flush started.
91  *
92  * @param work [in] The work to flush.
93  *
94  * @par Support System:
95  * linux liteos.
96  */
97 int osal_workqueue_flush(osal_workqueue *work);
98 
99 #ifdef __cplusplus
100 #if __cplusplus
101 }
102 #endif
103 #endif
104 #endif /* __OSAL_WORKQUEUE_H__ */