# libsst-concurrency

Cross-platform threading and synchronization primitives in C, with C++ RAII
wrappers in ZUtil.

## Primitives

| Primitive | C API prefix | C++ wrapper |
|---|---|---|
| Threads | `SST_Concurrency_*Thread*` | `ZThread` |
| Mutexes | `SST_Concurrency_*Mutex*` | `ZMutex` / `ZLock` |
| Events | `SST_Concurrency_*Event*` | `ZEvent` |
| Semaphores | `SST_Concurrency_*Semaphore*` | `ZSemaphore` |
| Thread-local storage | `SST_Concurrency_*TLS*` | -- |
| Read-write locks | `SST_Concurrency_*ReadWrite*` | `ZReadWriteLock` |
| One-time init | `SST_Concurrency_ExecOnce` | -- |
| Thread barriers | `SST_Concurrency_*ThreadBarrier*` | -- |

## Platform backends

| Primitive | POSIX | Win32 | Solaris | macOS |
|---|---|---|---|---|
| Thread | pthread | `_beginthreadex` | `thr_*` | pthread |
| Mutex | `pthread_mutex_t` | `CRITICAL_SECTION` | `mutex_t` | pthread |
| Event | `pthread_cond_t` | `CreateEvent` | `cond_t` | pthread |
| Semaphore | `sem_t` | `CreateSemaphore` | `sema_t` | Custom (cond+mutex) |
| TLS | `pthread_key_t` | `TlsAlloc` | `thr_keycreate` | pthread |

Read-write locks and thread barriers use atomic spinlocks on all platforms
(depends on libsst-atomic).
