17 #error "OS not supported" 41 pthread_mutex_t mutex;
50 return pthread_mutex_init(&om->mutex, NULL);
59 pthread_mutex_lock(&om->mutex);
68 pthread_mutex_unlock(&om->mutex);
75 os_mutex_destroy(
struct os_mutex *om)
77 pthread_mutex_destroy(&om->mutex);
99 typedef void *(*os_run_func)(
void *);
116 return pthread_create(&ost->thread, NULL, func, ptr);
127 pthread_join(ost->thread, &retval);
152 pthread_mutex_t mutex;
164 int ret = pthread_mutex_init(&oth->mutex, NULL);
169 ret = pthread_cond_init(&oth->cond, NULL);
171 pthread_mutex_destroy(&oth->mutex);
186 pthread_mutex_lock(&oth->mutex);
189 pthread_mutex_unlock(&oth->mutex);
193 int ret = pthread_create(&oth->thread, NULL, func, ptr);
195 pthread_mutex_unlock(&oth->mutex);
201 pthread_mutex_unlock(&oth->mutex);
215 pthread_mutex_lock(&oth->mutex);
218 pthread_mutex_unlock(&oth->mutex);
223 oth->running =
false;
226 pthread_cond_signal(&oth->cond);
229 pthread_mutex_unlock(&oth->mutex);
232 pthread_join(oth->thread, &retval);
244 os_thread_helper_stop(oth);
247 pthread_mutex_destroy(&oth->mutex);
248 pthread_cond_destroy(&oth->cond);
257 pthread_mutex_lock(&oth->mutex);
266 pthread_mutex_unlock(&oth->mutex);
288 pthread_cond_wait(&oth->cond, &oth->mutex);
299 pthread_cond_signal(&oth->cond);
Auto detect OS and certain features.
All in one helper that handles locking, waiting for change and starting a thread. ...
Definition: os_threading.h:149
#define U_ZERO(PTR)
Zeroes the correct amount of memory based on the type pointed-to by the argument. ...
Definition: u_misc.h:61
A wrapper around a native mutex.
Definition: os_threading.h:39
A wrapper around a native mutex.
Definition: os_threading.h:91
void *(* os_run_func)(void *)
Run function.
Definition: os_threading.h:99