|
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 const-locking utility for mutex-like synchronization primitives. More...
#include "jh/conceptual/mutex_like.h"Go to the source code of this file.
Classes | |
| class | jh::sync::const_lock< Mutex > |
Scope-based immutability barrier for mutex_like types. More... | |
Namespaces | |
| namespace | jh::sync |
| Aggregated entry point for synchronization and coordination facilities. | |
Scope-based const-locking utility for mutex-like synchronization primitives.
This header defines jh::sync::const_lock, a lightweight RAII-style synchronization helper that enforces immutability barriers for shared or exclusive access. It provides a unified locking abstraction compatible with all types satisfying jh::concepts::mutex_like.
When constructed, const_lock automatically acquires the appropriate lock:
shared_lockable, it uses lock_shared(). lock(). Upon destruction, it symmetrically releases the held lock.
If the supplied mutex is jh::typed::null_mutex_t, all operations are completely no-op, producing zero runtime overhead. This enables seamless single-threaded or thread-local use cases without conditional compilation.
Typical usage:
1.3.x
2025