Next: Optimizations of multithreaded code, Previous: The ISO C multithreading API, Up: Multithreading [Contents][Index]
The Gnulib multithreading API is documented in the respective include files:
<glthread/thread.h>
<glthread/lock.h>
<glthread/cond.h>
<glthread/tls.h>
<glthread/yield.h>
To make use of Gnulib multithreading, use the following Gnulib modules:
Purpose | Module |
---|---|
For thread creation and management: | thread |
For simple locks, recursive locks, and read-write locks: | lock |
For once-only execution: | lock |
For “condition variables” (wait queues): | cond |
For thread-local storage: | tls |
For relinquishing control: | yield |
The Gnulib multithreading supports a configure option ‘--enable-threads={isoc,posix,windows}’, that chooses the underlying thread implementation. Currently (2020):
--enable-threads=posix
is supported and is the best choice on all
platforms except for native Windows. It may also work, to a limited extent,
on mingw with the winpthreads
library, but is not recommended there.
--enable-threads=windows
is supported and is the best choice on
native Windows platforms (mingw and MSVC).
--enable-threads=isoc
is supported on all platforms that have the
ISO C multithreading API. However, --enable-threads=posix
is always
a better choice.