mulle-thread
🔠 Cross-platform thread/mutex/tss/atomic operations in C
mulle-thread is a set of C wrapper headers for a simplified subset of thread functions and for a limited range of atomic operations that strongly mimics the thread standard, even if thread is not available. On Windows it has to do a bit more work.
mulle-threads main advantages are simplicity, portability, sanity.
- basic atomic operations CAS, ++, -- on void pointers.
- basic thread operations
- mutex functionality
- thread local storage, with proper destruction
Since thread has <stdatomic.h>
and <threads.h>
, eventually this project
could become superflous. In the meantime though it's a convenient abstraction
on threads and atomic operations.
Warning
mulle_thread_once
doesn't guarantee, that exceptions or thread cancellation
within the init function will clear the once flag for a second run. In fact
it will not.
Release Version |
---|
API
You are here
Add
Use mulle-sde to add mulle-thread to your project:
mulle-sde dependency add --c --github mulle-concurrent mulle-thread
Install
mulle-sde
Use mulle-sde to build and install mulle-thread and all dependencies:
mulle-sde install --prefix /usr/local \
//github.com/mulle-concurrent/mulle-thread/archive/latest.tar.gz
Manual Installation
Install the requirements:
Requirements | Description |
---|---|
mulle-c11 | Compiler glue header |
mintomic | Don't build this! Unpack it into the mulle-thread folder and rename the directory to mintomic |
Install into /usr/local
:
mkdir build 2> /dev/null
(
cd build ;
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_PREFIX_PATH=/usr/local \
-DCMAKE_BUILD_TYPE=Release .. ;
make install
)
Platforms
- OS X
- iOS
- Linux
- FreeBSD
- Windows
Compilers
- clang
- gcc
- MSVC
thread support in clang as of v3.8 is lacking, as there is no
<threads.h>
. The fallback is pthreads.
Architectures
If <stdatomic.h>
is not available for your architecture, then mulle-thread
is limited to:
- x86
- x86_64
- arm
That is because of mintomic limitations. mintomic
is the original source for the provided atomic operations. Unfortunately it's not
really active anymore, so for example ARM64 doesn't work. mulle-thread will
use mintomic only, if <stdatomic.h>
is not available.
Author
Nat! for Mulle kybernetiK and Codeon GmbH