|
StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
|
A lightweight thread-owned lock with reentrant semantics for the owning thread. More...
#include <thread_lock.hxx>
A lightweight thread-owned lock with reentrant semantics for the owning thread.
ThreadLock tracks the owning thread and permits the owner thread to call Lock() multiple times without blocking (reentrant behavior for the owner). If a different thread calls Lock() while another thread owns the lock, that caller will block until the owning thread calls Unlock() and releases ownership.
This class is intended for simple ownership-based mutual exclusion where the same thread may need to acquire the lock multiple times. Unlock() releases ownership and makes the lock available to other threads. If a thread that does not own the lock calls Unlock(), the call is a no-op (it does not throw or alter state).