summaryrefslogtreecommitdiff
path: root/components/drivers/include/ipc/condvar.h
blob: ce240f47f3e6c93358689a153916583839bde670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-11-20     Shell        Add cond var API in kernel
 */

#ifndef IPC_CONDVAR_H__
#define IPC_CONDVAR_H__

#include <rtthread.h>

typedef struct rt_condvar
{
#ifdef USING_RT_OBJECT
    struct rt_object parent;
#endif
    rt_atomic_t waiters_cnt;
    rt_atomic_t waiting_mtx;
    struct rt_wqueue event;
} *rt_condvar_t;

void rt_condvar_init(rt_condvar_t cv, char *name);
int rt_condvar_timedwait(rt_condvar_t cv, rt_mutex_t mtx, int suspend_flag,
                         rt_tick_t timeout);
int rt_condvar_signal(rt_condvar_t cv);
int rt_condvar_broadcast(rt_condvar_t cv);

rt_inline void rt_condvar_detach(rt_condvar_t cv)
{
    RT_UNUSED(cv);
    return ;
}

#endif /* IPC_CONDVAR_H__ */