1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2023-11-20     Shell        Add cond var API in kernel
9  */
10 
11 #ifndef IPC_CONDVAR_H__
12 #define IPC_CONDVAR_H__
13 
14 #include <rtthread.h>
15 
16 typedef struct rt_condvar
17 {
18 #ifdef USING_RT_OBJECT
19     struct rt_object parent;
20 #endif
21     rt_atomic_t waiters_cnt;
22     rt_atomic_t waiting_mtx;
23     struct rt_wqueue event;
24 } *rt_condvar_t;
25 
26 void rt_condvar_init(rt_condvar_t cv, char *name);
27 int rt_condvar_timedwait(rt_condvar_t cv, rt_mutex_t mtx, int suspend_flag,
28                          rt_tick_t timeout);
29 int rt_condvar_signal(rt_condvar_t cv);
30 int rt_condvar_broadcast(rt_condvar_t cv);
31 
rt_condvar_detach(rt_condvar_t cv)32 rt_inline void rt_condvar_detach(rt_condvar_t cv)
33 {
34     RT_UNUSED(cv);
35     return ;
36 }
37 
38 #endif /* IPC_CONDVAR_H__ */
39