Monado OpenXR Runtime
Loading...
Searching...
No Matches
os_threading.h
Go to the documentation of this file.
1// Copyright 2019-2022, Collabora, Ltd.
2// Copyright 2024-2025, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Wrapper around OS threading native functions.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 *
9 * @ingroup aux_os
10 */
11
12#pragma once
13
14#include "xrt/xrt_compiler.h"
15#include "xrt/xrt_config_os.h"
16
17#include "util/u_misc.h"
18
19#include "os/os_time.h"
20
21#if defined(XRT_OS_OSX)
22#include <unistd.h>
23#include <pthread.h>
24#include <assert.h>
25
26#elif defined(XRT_OS_LINUX) || defined(XRT_ENV_MINGW)
27#include <unistd.h>
28#include <pthread.h>
29#include <semaphore.h>
30#include <assert.h>
31#define OS_THREAD_HAVE_SETNAME
32#define OS_THREAD_HAVE_SEMAPHORE
33
34#elif defined(XRT_OS_WINDOWS)
35#include "xrt/xrt_windows.h"
36#include <pthread.h>
37#include <sched.h>
38#include <semaphore.h>
39#include <assert.h>
40#define OS_THREAD_HAVE_SETNAME
41#define OS_THREAD_HAVE_SEMAPHORE
42
43#else
44
45#error "OS not supported"
46
47#endif
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53
54/*!
55 * @addtogroup aux_os
56 * @{
57 */
58
59/*
60 *
61 * Mutex
62 *
63 */
64
65/*!
66 * A wrapper around a native mutex.
67 */
69{
70 pthread_mutex_t mutex;
71
72#ifndef NDEBUG
73 bool initialized;
74 bool recursive;
75#endif
76};
77
78/*!
79 * Init.
80 *
81 * @public @memberof os_mutex
82 */
83static inline int
85{
86 assert(!om->initialized);
87#ifndef NDEBUG
88 om->initialized = true;
89 om->recursive = false;
90#endif
91 return pthread_mutex_init(&om->mutex, NULL);
92}
93
94/*!
95 * Lock.
96 *
97 * @public @memberof os_mutex
98 */
99static inline void
101{
102 assert(om->initialized);
103 pthread_mutex_lock(&om->mutex);
104}
105
106/*!
107 * Try to lock, but do not block.
108 *
109 * @public @memberof os_mutex
110 */
111static inline int
113{
114 assert(om->initialized);
115 return pthread_mutex_trylock(&om->mutex);
116}
117
118/*!
119 * Unlock.
120 *
121 * @public @memberof os_mutex
122 */
123static inline void
125{
126 assert(om->initialized);
127 pthread_mutex_unlock(&om->mutex);
128}
129
130/*!
131 * Clean up.
132 *
133 * @public @memberof os_mutex
134 */
135static inline void
137{
138 assert(om->initialized);
139 assert(!om->recursive);
140
141 pthread_mutex_destroy(&om->mutex);
142
143#ifndef NDEBUG
144 om->initialized = false;
145 om->recursive = false;
146#endif
147}
148
149/*!
150 * Init.
151 *
152 * @public @memberof os_mutex
153 */
154static inline int
156{
157 assert(!om->initialized);
158
159#ifndef NDEBUG
160 om->initialized = true;
161 om->recursive = true;
162#endif
163
164 pthread_mutexattr_t attr;
165 pthread_mutexattr_init(&attr);
166 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
167 int ret = pthread_mutex_init(&om->mutex, &attr);
168 pthread_mutexattr_destroy(&attr);
169
170 return ret;
171}
172
173/*!
174 * Clean up.
175 *
176 * @public @memberof os_mutex
177 */
178static inline void
180{
181 assert(om->initialized);
182 assert(om->recursive);
183
184 pthread_mutex_destroy(&om->mutex);
185
186#ifndef NDEBUG
187 om->initialized = false;
188 om->recursive = false;
189#endif
190}
191
192
193/*
194 *
195 * Read-write lock.
196 *
197 */
198
199/*!
200 * A wrapper around a native read-write lock.
201 */
203{
204 pthread_rwlock_t rwlock;
205
206#ifndef NDEBUG
207 bool initialized;
208#endif
209};
210
211/*!
212 * Init.
213 *
214 * @public @memberof os_rwlock
215 */
216static inline int
218{
219 assert(!orwl->initialized);
220#ifndef NDEBUG
221 orwl->initialized = true;
222#endif
223 return pthread_rwlock_init(&orwl->rwlock, NULL);
224}
225
226/*!
227 * Lock for reading, any number of readers can hold it at the same time.
228 *
229 * @public @memberof os_rwlock
230 */
231static inline void
233{
234 assert(orwl->initialized);
235 pthread_rwlock_rdlock(&orwl->rwlock);
236}
237
238/*!
239 * Lock for writing, waits for all readers and writers to unlock.
240 *
241 * @public @memberof os_rwlock
242 */
243static inline void
245{
246 assert(orwl->initialized);
247 pthread_rwlock_wrlock(&orwl->rwlock);
248}
249
250/*!
251 * Unlock, from either a read or a write lock.
252 *
253 * @public @memberof os_rwlock
254 */
255static inline void
257{
258 assert(orwl->initialized);
259 pthread_rwlock_unlock(&orwl->rwlock);
260}
261
262/*!
263 * Clean up.
264 *
265 * @public @memberof os_rwlock
266 */
267static inline void
269{
270 assert(orwl->initialized);
271
272 pthread_rwlock_destroy(&orwl->rwlock);
273
274#ifndef NDEBUG
275 orwl->initialized = false;
276#endif
277}
278
279
280/*
281 *
282 * Conditional variable.
283 *
284 */
285
286/*!
287 * A wrapper around a native conditional variable.
288 */
290{
291 pthread_cond_t cond;
292#ifndef NDEBUG
293 bool initialized;
294#endif
295};
296
297/*!
298 * Init.
299 *
300 * @public @memberof os_cond
301 */
302static inline int
304{
305 assert(!oc->initialized);
306#ifndef NDEBUG
307 oc->initialized = true;
308#endif
309 return pthread_cond_init(&oc->cond, NULL);
310}
311
312/*!
313 * Signal.
314 *
315 * @public @memberof os_cond
316 */
317static inline void
319{
320 assert(oc->initialized);
321 pthread_cond_signal(&oc->cond);
322}
323
324/*!
325 * Broadcast (signal to multiple threads).
326 *
327 * @public @memberof os_cond
328 */
329static inline int
331{
332 assert(oc->initialized);
333 return pthread_cond_broadcast(&oc->cond);
334}
335
336/*!
337 * Wait.
338 *
339 * Be sure to call this in a loop, testing some other condition that you
340 * are actually waiting for, as condition variable waits are subject to
341 * spurious wakeups.
342 *
343 * Must be called with the mutex @p om locked.
344 *
345 * Once the wait begins, the mutex @p om is unlocked, to allow another
346 * thread access to change the thing you're monitoring. By the time this
347 * returns, you once again own the lock.
348 *
349 * @public @memberof os_cond
350 */
351static inline void
352os_cond_wait(struct os_cond *oc, struct os_mutex *om)
353{
354 assert(oc->initialized);
355 pthread_cond_wait(&oc->cond, &om->mutex);
356}
357
358/*!
359 * Clean up.
360 *
361 * @public @memberof os_cond
362 */
363static inline void
365{
366 assert(oc->initialized);
367 pthread_cond_destroy(&oc->cond);
368#ifndef NDEBUG
369 oc->initialized = false;
370#endif
371}
372
373
374
375/*
376 *
377 * Thread.
378 *
379 */
380
381/*!
382 * A wrapper around a native thread.
383 */
385{
386 pthread_t thread;
387};
388
389/*!
390 * Run function.
391 *
392 * @public @memberof os_thread
393 */
394typedef void *(*os_run_func_t)(void *);
395
396/*!
397 * Init.
398 *
399 * @public @memberof os_thread
400 */
401static inline int
403{
404 return 0;
405}
406
407/*!
408 * Start thread.
409 *
410 * @public @memberof os_thread
411 */
412static inline int
413os_thread_start(struct os_thread *ost, os_run_func_t func, void *ptr)
414{
415 return pthread_create(&ost->thread, NULL, func, ptr);
416}
417
418/*!
419 * Join.
420 *
421 * @public @memberof os_thread
422 */
423static inline void
425{
426 void *retval;
427
428 pthread_join(ost->thread, &retval);
429 U_ZERO(&ost->thread);
430}
431
432/*!
433 * Destruction.
434 *
435 * @public @memberof os_thread
436 */
437static inline void
439{}
440
441/*!
442 * Gets the number of hardware threads available.
443 */
444static inline int64_t
446{
447#if defined(XRT_OS_LINUX) || defined(XRT_OS_OSX)
448 return (int64_t)sysconf(_SC_NPROCESSORS_ONLN);
449#elif defined(XRT_OS_WINDOWS)
450 SYSTEM_INFO sysinfo = XRT_STRUCT_INIT;
451 GetSystemInfo(&sysinfo);
452 return (int64_t)sysinfo.dwNumberOfProcessors;
453#else
454#error "OS not supported"
455 return -1;
456#endif
457}
458
459/*!
460 * Make a best effort to name the current thread.
461 *
462 * Due to an easy race condition caused by musl starting threads before the
463 * handle is written into memory, only this function is exposed, since
464 * it is the safer option when called by the thread itself.
465 */
466static inline void
467os_thread_name_self(const char *name)
468{
469#ifdef OS_THREAD_HAVE_SETNAME
470 pthread_setname_np(pthread_self(), name);
471#else
472 (void)name;
473#endif
474}
475
476#ifdef OS_THREAD_HAVE_SEMAPHORE
477/*
478 *
479 * Semaphore.
480 *
481 */
482
483/*!
484 * A wrapper around a native semaphore.
485 */
487{
488 sem_t sem;
489};
490
491/*!
492 * Init.
493 *
494 * @public @memberof os_semaphore
495 */
496static inline int
497os_semaphore_init(struct os_semaphore *os, int count)
498{
499 return sem_init(&os->sem, 0, count);
500}
501
502/*!
503 * Release.
504 *
505 * @public @memberof os_semaphore
506 */
507static inline void
509{
510 sem_post(&os->sem);
511}
512
513/*!
514 * Set @p ts to the current time, plus the timeout_ns value.
515 *
516 * Intended for use by the threading code only: the timestamps are not interchangeable with other sources of time.
517 *
518 * @public @memberof os_semaphore
519 */
520static inline int
521os_semaphore_get_realtime_clock(struct timespec *ts, uint64_t timeout_ns)
522{
523#if defined(XRT_OS_WINDOWS) && !defined(XRT_ENV_MINGW)
524 struct timespec relative;
525 os_ns_to_timespec(timeout_ns, &relative);
526 pthread_win32_getabstime_np(ts, &relative);
527 return 0;
528#else
529 struct timespec now;
530 if (clock_gettime(CLOCK_REALTIME, &now) < 0) {
531 assert(false);
532 return -1;
533 }
534 uint64_t now_ns = os_timespec_to_ns(&now);
535 uint64_t when_ns = timeout_ns + now_ns;
536
537 os_ns_to_timespec(when_ns, ts);
538 return 0;
539#endif
540}
541
542/*!
543 * Wait, if @p timeout_ns is zero then waits forever.
544 *
545 * @public @memberof os_semaphore
546 */
547static inline void
548os_semaphore_wait(struct os_semaphore *os, uint64_t timeout_ns)
549{
550 if (timeout_ns == 0) {
551 sem_wait(&os->sem);
552 return;
553 }
554
555 struct timespec abs_timeout;
556 if (os_semaphore_get_realtime_clock(&abs_timeout, timeout_ns) == -1) {
557 assert(false);
558 }
559
560 sem_timedwait(&os->sem, &abs_timeout);
561}
562
563/*!
564 * Clean up.
565 *
566 * @public @memberof os_semaphore
567 */
568static inline void
570{
571 sem_destroy(&os->sem);
572}
573#endif // OS_THREAD_HAVE_SEMAPHORE
574
575
576/*
577 *
578 * Fancy helper.
579 *
580 */
581
582/*!
583 * All in one helper that handles locking, waiting for change and starting a
584 * thread.
585 */
587{
588 pthread_t thread;
589 pthread_mutex_t mutex;
590 pthread_cond_t cond;
591
592 bool initialized;
593 bool running;
594};
595
596/*!
597 * Initialize the thread helper.
598 *
599 * @public @memberof os_thread_helper
600 */
601static inline int
603{
604 U_ZERO(oth);
605
606 int ret = pthread_mutex_init(&oth->mutex, NULL);
607 if (ret != 0) {
608 return ret;
609 }
610
611 ret = pthread_cond_init(&oth->cond, NULL);
612 if (ret) {
613 pthread_mutex_destroy(&oth->mutex);
614 return ret;
615 }
616 oth->initialized = true;
617
618 return 0;
619}
620
621/*!
622 * Start the internal thread.
623 *
624 * @public @memberof os_thread_helper
625 */
626static inline int
627os_thread_helper_start(struct os_thread_helper *oth, os_run_func_t func, void *ptr)
628{
629 pthread_mutex_lock(&oth->mutex);
630
631 assert(oth->initialized);
632 if (oth->running) {
633 pthread_mutex_unlock(&oth->mutex);
634 return -1;
635 }
636
637 int ret = pthread_create(&oth->thread, NULL, func, ptr);
638 if (ret != 0) {
639 pthread_mutex_unlock(&oth->mutex);
640 return ret;
641 }
642
643 oth->running = true;
644
645 pthread_mutex_unlock(&oth->mutex);
646
647 return 0;
648}
649
650/*!
651 * @brief Signal from within the thread that we are stopping.
652 *
653 * Call with mutex unlocked - it takes and releases the lock internally.
654 *
655 * @public @memberof os_thread_helper
656 */
657static inline int
659{
660 // The fields are protected.
661 pthread_mutex_lock(&oth->mutex);
662 assert(oth->initialized);
663
664 // Report we're stopping the thread.
665 oth->running = false;
666
667 // Wake up any waiting thread.
668 pthread_cond_signal(&oth->cond);
669
670 // No longer need to protect fields.
671 pthread_mutex_unlock(&oth->mutex);
672
673 return 0;
674}
675
676/*!
677 * @brief Stop the thread and wait for it to exit.
678 *
679 * Call with mutex unlocked - it takes and releases the lock internally.
680 *
681 * @public @memberof os_thread_helper
682 */
683static inline int
685{
686 void *retval = NULL;
687
688 // The fields are protected.
689 pthread_mutex_lock(&oth->mutex);
690 assert(oth->initialized);
691
692 if (!oth->running) {
693 // it already exited
694 pthread_mutex_unlock(&oth->mutex);
695 return 0;
696 }
697
698 // Stop the thread.
699 oth->running = false;
700
701 // Wake up the thread if it is waiting.
702 pthread_cond_signal(&oth->cond);
703
704 // No longer need to protect fields.
705 pthread_mutex_unlock(&oth->mutex);
706
707 // Wait for thread to finish.
708 pthread_join(oth->thread, &retval);
709
710 return 0;
711}
712
713/*!
714 * Destroy the thread helper, externally synchronizable.
715 *
716 * Integrates a call to @ref os_thread_helper_stop_and_wait, so you may just call this for full cleanup
717 *
718 * @public @memberof os_thread_helper
719 */
720static inline void
722{
723 assert(oth->initialized);
724 // Stop the thread.
725 os_thread_helper_stop_and_wait(oth);
726
727 // Destroy resources.
728 pthread_mutex_destroy(&oth->mutex);
729 pthread_cond_destroy(&oth->cond);
730 oth->initialized = false;
731}
732
733/*!
734 * Lock the helper.
735 *
736 * @public @memberof os_thread_helper
737 */
738static inline void
740{
741 pthread_mutex_lock(&oth->mutex);
742}
743
744/*!
745 * Unlock the helper.
746 *
747 * @public @memberof os_thread_helper
748 */
749static inline void
751{
752 pthread_mutex_unlock(&oth->mutex);
753}
754
755/*!
756 * Is the thread running, or supposed to be running.
757 *
758 * Call with mutex unlocked - it takes and releases the lock internally.
759 * If you already have a lock, use os_thread_helper_is_running_locked().
760 *
761 * @public @memberof os_thread_helper
762 */
763static inline bool
765{
766 os_thread_helper_lock(oth);
767 assert(oth->initialized);
768 bool ret = oth->running;
769 os_thread_helper_unlock(oth);
770 return ret;
771}
772
773/*!
774 * Is the thread running, or supposed to be running.
775 *
776 * Must be called with the helper locked.
777 * If you don't have the helper locked for some other reason already,
778 * you can use os_thread_helper_is_running()
779 *
780 * @public @memberof os_thread_helper
781 */
782static inline bool
784{
785 return oth->running;
786}
787
788/*!
789 * Wait for a signal.
790 *
791 * Be sure to call this in a loop, testing some other condition that you
792 * are actually waiting for, as this is backed by a condition variable
793 * wait and is thus subject to spurious wakeups.
794 *
795 * Must be called with the helper locked.
796 *
797 * As this wraps a cond-var wait, once the wait begins, the helper is
798 * unlocked, to allow another thread access to change the thing you're
799 * monitoring. By the time this returns, you once again own the lock.
800 *
801 * @public @memberof os_thread_helper
802 */
803static inline void
805{
806 pthread_cond_wait(&oth->cond, &oth->mutex);
807}
808
809/*!
810 * Signal a waiting thread to wake up.
811 *
812 * Must be called with the helper locked.
813 *
814 * @public @memberof os_thread_helper
815 */
816static inline void
818{
819 pthread_cond_signal(&oth->cond);
820}
821
822/*!
823 * @}
824 */
825
826
827#ifdef __cplusplus
828} // extern "C"
829#endif
830
831
832#ifdef __cplusplus
833namespace xrt::auxiliary::os {
834
835
836//! A class owning an @ref os_mutex
837class Mutex
838{
839public:
840 //! Construct a mutex
841 Mutex() noexcept
842 {
843 os_mutex_init(&inner_);
844 }
845 //! Destroy a mutex when it goes out of scope
846 ~Mutex()
847 {
848 os_mutex_destroy(&inner_);
849 }
850
851 //! Block until the lock can be taken.
852 void
853 lock() noexcept
854 {
855 os_mutex_lock(&inner_);
856 }
857
858 //! Take the lock and return true if possible, but do not block
859 bool
860 try_lock() noexcept
861 {
862 return 0 == os_mutex_trylock(&inner_);
863 }
864
865 //! Release the lock
866 void
867 unlock() noexcept
868 {
869 os_mutex_unlock(&inner_);
870 }
871
872 //! Get a pointer to the owned mutex: do not delete it!
873 os_mutex *
874 get_inner() noexcept
875 {
876 return &inner_;
877 }
878
879 // Do not copy or delete these mutexes.
880 Mutex(Mutex const &) = delete;
881 Mutex(Mutex &&) = delete;
882 Mutex &
883 operator=(Mutex const &) = delete;
884 Mutex &
885 operator=(Mutex &&) = delete;
886
887private:
888 os_mutex inner_{};
889};
890
891} // namespace xrt::auxiliary::os
892
893#endif // __cplusplus
static int64_t os_timespec_to_ns(const struct timespec *spec)
Convert a timespec struct to nanoseconds.
Definition os_time.h:273
static void os_ns_to_timespec(int64_t ns, struct timespec *spec)
Convert an nanosecond integer to a timespec struct.
Definition os_time.h:282
static void os_rwlock_destroy(struct os_rwlock *orwl)
Clean up.
Definition os_threading.h:268
static int os_rwlock_init(struct os_rwlock *orwl)
Init.
Definition os_threading.h:217
static void os_mutex_recursive_destroy(struct os_mutex *om)
Clean up.
Definition os_threading.h:179
static bool os_thread_helper_is_running_locked(struct os_thread_helper *oth)
Is the thread running, or supposed to be running.
Definition os_threading.h:783
static int os_cond_broadcast(struct os_cond *oc)
Broadcast (signal to multiple threads).
Definition os_threading.h:330
static int os_thread_helper_start(struct os_thread_helper *oth, os_run_func_t func, void *ptr)
Start the internal thread.
Definition os_threading.h:627
static void os_rwlock_unlock(struct os_rwlock *orwl)
Unlock, from either a read or a write lock.
Definition os_threading.h:256
static int os_mutex_init(struct os_mutex *om)
Init.
Definition os_threading.h:84
static int os_semaphore_get_realtime_clock(struct timespec *ts, uint64_t timeout_ns)
Set ts to the current time, plus the timeout_ns value.
Definition os_threading.h:521
static void os_thread_helper_signal_locked(struct os_thread_helper *oth)
Signal a waiting thread to wake up.
Definition os_threading.h:817
static void os_mutex_lock(struct os_mutex *om)
Lock.
Definition os_threading.h:100
static void os_cond_wait(struct os_cond *oc, struct os_mutex *om)
Wait.
Definition os_threading.h:352
static int os_thread_helper_stop_and_wait(struct os_thread_helper *oth)
Stop the thread and wait for it to exit.
Definition os_threading.h:684
static void os_thread_destroy(struct os_thread *ost)
Destruction.
Definition os_threading.h:438
static void os_semaphore_release(struct os_semaphore *os)
Release.
Definition os_threading.h:508
static void os_thread_name_self(const char *name)
Make a best effort to name the current thread.
Definition os_threading.h:467
static void os_thread_join(struct os_thread *ost)
Join.
Definition os_threading.h:424
static int os_thread_start(struct os_thread *ost, os_run_func_t func, void *ptr)
Start thread.
Definition os_threading.h:413
static int os_thread_helper_signal_stop(struct os_thread_helper *oth)
Signal from within the thread that we are stopping.
Definition os_threading.h:658
static int os_mutex_recursive_init(struct os_mutex *om)
Init.
Definition os_threading.h:155
static void os_thread_helper_wait_locked(struct os_thread_helper *oth)
Wait for a signal.
Definition os_threading.h:804
static int os_semaphore_init(struct os_semaphore *os, int count)
Init.
Definition os_threading.h:497
static int os_thread_init(struct os_thread *ost)
Init.
Definition os_threading.h:402
static void os_cond_signal(struct os_cond *oc)
Signal.
Definition os_threading.h:318
static int64_t os_hardware_thread_count(void)
Gets the number of hardware threads available.
Definition os_threading.h:445
static int os_mutex_trylock(struct os_mutex *om)
Try to lock, but do not block.
Definition os_threading.h:112
static void os_thread_helper_unlock(struct os_thread_helper *oth)
Unlock the helper.
Definition os_threading.h:750
static int os_thread_helper_init(struct os_thread_helper *oth)
Initialize the thread helper.
Definition os_threading.h:602
static int os_cond_init(struct os_cond *oc)
Init.
Definition os_threading.h:303
static void os_rwlock_write_lock(struct os_rwlock *orwl)
Lock for writing, waits for all readers and writers to unlock.
Definition os_threading.h:244
static void os_thread_helper_destroy(struct os_thread_helper *oth)
Destroy the thread helper, externally synchronizable.
Definition os_threading.h:721
static void os_rwlock_read_lock(struct os_rwlock *orwl)
Lock for reading, any number of readers can hold it at the same time.
Definition os_threading.h:232
static bool os_thread_helper_is_running(struct os_thread_helper *oth)
Is the thread running, or supposed to be running.
Definition os_threading.h:764
static void os_mutex_unlock(struct os_mutex *om)
Unlock.
Definition os_threading.h:124
static void os_mutex_destroy(struct os_mutex *om)
Clean up.
Definition os_threading.h:136
static void os_semaphore_destroy(struct os_semaphore *os)
Clean up.
Definition os_threading.h:569
static void os_thread_helper_lock(struct os_thread_helper *oth)
Lock the helper.
Definition os_threading.h:739
static void os_cond_destroy(struct os_cond *oc)
Clean up.
Definition os_threading.h:364
static void os_semaphore_wait(struct os_semaphore *os, uint64_t timeout_ns)
Wait, if timeout_ns is zero then waits forever.
Definition os_threading.h:548
#define U_ZERO(PTR)
Zeroes the correct amount of memory based on the type pointed-to by the argument.
Definition u_misc.h:68
#define XRT_STRUCT_INIT
Very small default init for structs that works in both C and C++.
Definition xrt_compiler.h:311
Wrapper around OS native time functions.
A wrapper around a native conditional variable.
Definition os_threading.h:290
A wrapper around a native mutex.
Definition os_threading.h:69
A wrapper around a native read-write lock.
Definition os_threading.h:203
A wrapper around a native semaphore.
Definition os_threading.h:487
All in one helper that handles locking, waiting for change and starting a thread.
Definition os_threading.h:587
A wrapper around a native thread.
Definition os_threading.h:385
Definition u_worker.c:38
Very small misc utils.
Header holding common defines.
Auto detect OS and certain features.
A minimal way to include Windows.h.