Native C threads
suggest changeC11 introduced the optional <threads.h> library. Test the correctly spelled feature-test macro before depending on it:
#ifdef __STDC_NO_THREADS__
#error "This program requires the standard C threads library"
#else
#include <threads.h>
#endif
The library provides five groups of facilities:
- Thread management:
thrd_create,thrd_current,thrd_equal,thrd_join,thrd_detach,thrd_exit,thrd_sleep, andthrd_yield. - Mutexes:
mtx_init,mtx_lock,mtx_trylock,mtx_timedlock,mtx_unlock, andmtx_destroy. - Condition variables:
cnd_init,cnd_wait,cnd_timedwait,cnd_signal,cnd_broadcast, andcnd_destroy. - One-time initialization:
call_once. - Thread-specific storage:
tss_create,tss_get,tss_set, andtss_delete.
Do not maintain a fixed list of supporting libraries in application code or documentation; implementation support changes over time. Consult the compiler and C library documentation for the platforms you target.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents