6 #ifndef ABTI_COND_H_INCLUDED
7 #define ABTI_COND_H_INCLUDED
13 static inline void ABTI_cond_init(ABTI_cond *p_cond)
15 ABTD_spinlock_clear(&p_cond->lock);
16 p_cond->p_waiter_mutex = NULL;
17 ABTI_waitlist_init(&p_cond->waitlist);
20 static inline void ABTI_cond_fini(ABTI_cond *p_cond)
25 ABTD_spinlock_acquire(&p_cond->lock);
26 ABTI_UB_ASSERT(ABTI_waitlist_is_empty(&p_cond->waitlist));
29 static inline ABTI_cond *ABTI_cond_get_ptr(
ABT_cond cond)
31 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
36 p_cond = (ABTI_cond *)cond;
40 return (ABTI_cond *)cond;
44 static inline ABT_cond ABTI_cond_get_handle(ABTI_cond *p_cond)
46 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
60 ABTI_cond_wait(ABTI_local **pp_local, ABTI_cond *p_cond, ABTI_mutex *p_mutex)
62 ABTD_spinlock_acquire(&p_cond->lock);
64 if (p_cond->p_waiter_mutex == NULL) {
65 p_cond->p_waiter_mutex = p_mutex;
67 if (p_cond->p_waiter_mutex != p_mutex) {
68 ABTD_spinlock_release(&p_cond->lock);
73 ABTI_mutex_unlock(*pp_local, p_mutex);
74 ABTI_waitlist_wait_and_unlock(pp_local, &p_cond->waitlist, &p_cond->lock,
77 ABTI_mutex_lock(pp_local, p_mutex);
81 static inline void ABTI_cond_broadcast(ABTI_local *p_local, ABTI_cond *p_cond)
83 ABTD_spinlock_acquire(&p_cond->lock);
85 ABTI_waitlist_broadcast(p_local, &p_cond->waitlist);
86 ABTD_spinlock_release(&p_cond->lock);