25 #ifndef MCR_UTIL_CPPTHREAD_H_ 26 #define MCR_UTIL_CPPTHREAD_H_ 28 #include "mcr/globals.h" 47 #define __restrict restrict 65 mtx_recursive = 1 << 0,
72 typedef int once_flag;
74 typedef int (*thrd_start_t)(
void *);
92 MCR_API
int thrd_create(thrd_t * thr, thrd_start_t func,
void *arg);
93 MCR_API
int thrd_equal(thrd_t lhs, thrd_t rhs);
94 MCR_API thrd_t thrd_current();
95 MCR_API
int thrd_sleep(
const struct timespec *time_point,
97 MCR_API
void thrd_yield();
98 _Noreturn
void thrd_exit(
int res);
99 MCR_API
int thrd_detach(thrd_t thr);
100 MCR_API
int thrd_join(thrd_t thr,
int *res);
101 MCR_API
void mcr_thrd_delete(thrd_t * thr);
106 MCR_API
int mtx_init(
mtx_t * mutex,
int type);
107 MCR_API
int mtx_lock(
mtx_t * mutex);
108 MCR_API
int mtx_timedlock(
mtx_t * __restrict mutex,
109 const struct timespec *__restrict time_point);
110 MCR_API
int mtx_trylock(
mtx_t * mutex);
111 MCR_API
int mtx_unlock(
mtx_t * mutex);
112 MCR_API
void mtx_destroy(
mtx_t * mutex);
117 MCR_API
int cnd_init(cnd_t * cond);
118 MCR_API
int cnd_signal(cnd_t * cond);
119 MCR_API
int cnd_broadcast(cnd_t * cond);
124 const struct timespec *__restrict time_point);
125 MCR_API
void cnd_destroy(cnd_t * cond);
MCR_API int cnd_timedwait(cnd_t *cond, mtx_t *mutex, const struct timespec *time_point)
MCR_API int cnd_wait(cnd_t *cond, mtx_t *mutex)
MCR_API int thrd_sleep_until(struct tm *time_point)