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.
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 | 
|---|
| Release Version | Release Notes | AI Documentation | 
|---|---|---|
| RELEASENOTES | DeepWiki for mulle-thread | 
An easy way to get a locked code region is to use:
void   foo( mulle_thread_mutex_t *mutex)
{
   mulle_thread_mutex_do( mutex)
   {
      // code block is now executed with mutex locked
   }
   // mutex is unlocked again
}break and continue will exit the block and unlock the mutex. But when you
use return the function exists and the mutex remains locked.
This project is a component of the mulle-core library. As such you usually will not add or install it
individually, unless you specifically do not want to link against
mulle-core.
Use mulle-sde to add mulle-thread to your project:
mulle-sde add github:mulle-concurrent/mulle-threadTo only add the sources of mulle-thread with dependency sources use clib:
clib install --out src/mulle-concurrent mulle-concurrent/mulle-threadAdd -isystem src/mulle-concurrent to your CFLAGS and compile all the sources that were downloaded with your project.
Use mulle-sde to build and install mulle-thread and all dependencies:
mulle-sde install --prefix /usr/local \
   https://github.com/mulle-concurrent/mulle-thread/archive/latest.tar.gzInstall the requirements:
| Requirements | Description | 
|---|---|
| mulle-c11 | 🔀 Cross-platform C compiler glue (and some cpp conveniences) | 
Download the latest tar or zip archive and unpack it.
Install mulle-thread into /usr/local with cmake:
PREFIX_DIR="/usr/local"
cmake -B build                               \
      -DMULLE_SDK_PATH="${PREFIX_DIR}"       \
      -DCMAKE_INSTALL_PREFIX="${PREFIX_DIR}" \
      -DCMAKE_PREFIX_PATH="${PREFIX_DIR}"    \
      -DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config ReleaseNat! for Mulle kybernetiK