|
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
|
Lazy RAII lock for a single wrapper layer. More...
#include <wrapper_lock.h>
Public Member Functions | |
| wrapper_lock (Refer ref) | |
Constructs the lock storing ref. No guard is acquired. | |
| ~wrapper_lock () | |
| Releases the guard if it was acquired. | |
| void | lock () |
| Acquires the guard on the executor (idempotent). | |
| void | unlock () |
| Releases the guard on the executor (idempotent). | |
| decltype(auto) | value () const noexcept |
| Returns the inner value through the executor. | |
| Refer | wrapper_value () const noexcept |
| Returns the wrapper reference itself without requiring the lock. | |
Lazy RAII lock for a single wrapper layer.
Stores the wrapper reference and a reference to its executor, but does not call guard() at construction. The guard is activated only when lock() is called explicitly, and released when unlock() is called or the object is destroyed.
For non-wrapper types lock() / unlock() are no-ops and value() returns the reference unchanged.
| Refer | Reference type — either wrapper<V,E> cv-ref or a plain value cv-ref. |
|
explicit |
Constructs the lock storing ref. No guard is acquired.
| ref | Reference to the wrapper or plain value to lock. |
| scl::wrapper_lock< Refer >::~wrapper_lock | ( | ) |
Releases the guard if it was acquired.
Calls unlock(). noexcept if executor_type::unguard() does not exist or is noexcept (see is_unguard_noexcept_v).
| void scl::wrapper_lock< Refer >::lock | ( | ) |
Acquires the guard on the executor (idempotent).
For wrapper types calls executor_type::guard() on the first call; subsequent calls are no-ops. For non-wrapper types always a no-op. noexcept if executor_type::guard() does not exist or is noexcept (see is_guard_noexcept_v).
| void scl::wrapper_lock< Refer >::unlock | ( | ) |
Releases the guard on the executor (idempotent).
For wrapper types calls executor_type::unguard() if the guard is held, then clears the locked flag. Subsequent calls are no-ops. For non-wrapper types always a no-op. noexcept if executor_type::unguard() does not exist or is noexcept (see is_unguard_noexcept_v).
|
nodiscardnoexcept |
Returns the inner value through the executor.
For wrapper types delegates to executor_type::access(). For non-wrapper types returns the held reference unchanged.
lock() must have been called beforehand.
|
nodiscardnoexcept |
Returns the wrapper reference itself without requiring the lock.
Only available for wrapper types.