2 #ifndef __MONO_COOP_SEMAPHORE_H__
3 #define __MONO_COOP_SEMAPHORE_H__
8 #include "mono-os-semaphore.h"
9 #include "mono-threads.h"
13 /* We put the OS sync primitives in struct, so the compiler will warn us if
14 * we use mono_os_(mutex|cond|sem)_... on MonoCoop(Mutex|Cond|Sem) structures */
16 typedef struct _MonoCoopSem MonoCoopSem;
22 mono_coop_sem_init (MonoCoopSem *sem, int value)
24 return mono_os_sem_init (&sem->s, value);
28 mono_coop_sem_destroy (MonoCoopSem *sem)
30 return mono_os_sem_destroy (&sem->s);
34 mono_coop_sem_wait (MonoCoopSem *sem, MonoSemFlags flags)
38 MONO_PREPARE_BLOCKING;
40 res = mono_os_sem_wait (&sem->s, flags);
48 mono_coop_sem_timedwait (MonoCoopSem *sem, guint timeout_ms, MonoSemFlags flags)
52 MONO_PREPARE_BLOCKING;
54 res = mono_os_sem_timedwait (&sem->s, timeout_ms, flags);
62 mono_coop_sem_post (MonoCoopSem *sem)
64 return mono_os_sem_post (&sem->s);
69 #endif /* __MONO_COOP_SEMAPHORE_H__ */