|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Scope-based immutability barrier for mutex_like types.
More...
#include <jh/synchronous/const_lock.h>
Public Member Functions | |
| const_lock (Mutex &m) noexcept | |
| Constructs the guard and acquires the lock. | |
| const_lock (const const_lock &)=delete | |
| const_lock & | operator= (const const_lock &)=delete |
| const_lock (const const_lock &&)=delete | |
| const_lock & | operator= (const const_lock &&)=delete |
| ~const_lock () noexcept | |
| Destroys the guard and releases the lock. | |
Scope-based immutability barrier for mutex_like types.
A lightweight RAII guard that acquires either a shared or exclusive lock on construction and releases it on destruction.
Mutex satisfies shared_lockable, lock_shared() / unlock_shared() are used. lock() / unlock() are used. Mutex is jh::typed::null_mutex_t, all operations are no-op. Intended for const or read-only critical sections where immutability must be preserved across threads.
const_lock protected scope constitutes undefined behavior (UB). Even if the underlying mutex is exclusive-only (e.g. std::mutex), the logical semantics remain read-only protection.| Mutex | Any type satisfying jh::concepts::mutex_like. |
|
inlineexplicitnoexcept |
Constructs the guard and acquires the lock.
| m | Reference to a mutex-like object. |