|
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
|
Recursive lazy RAII lock through a wrapper chain. More...
#include <value_lock.h>
Public Member Functions | |
| value_lock (Refer ref) | |
| Constructs the lock, capturing references to every executor in the wrapper chain. No guard is acquired at construction. | |
| ~value_lock () | |
Releases all guards acquired via lock_for(). | |
| template<typename Target> requires ::scl::feature::concepts::convertible_from<Target, Refer> | |
| void | lock_for () |
Activates guards for every wrapper layer needed to reach Target. | |
| template<typename Target> requires ::scl::feature::concepts::convertible_from<Target, Refer> | |
| Target | value_as () |
Returns the stored value at the level matching Target. | |
Recursive lazy RAII lock through a wrapper chain.
Stores references to every executor in the wrapper chain but does not acquire any guard at construction. Guards are activated lazily via lock_for<Target>(), which locks only the layers required to reach Target, and released automatically on destruction.
For non-wrapper types lock_for() / value_as() are no-ops / direct reference passes.
| Refer | Reference type — either wrapper<V,E> cv-ref or a plain value cv-ref. |
|
explicit |
Constructs the lock, capturing references to every executor in the wrapper chain. No guard is acquired at construction.
| ref | Reference to the outermost wrapper or plain value. |
| scl::value_lock< Refer >::~value_lock | ( | ) |
Releases all guards acquired via lock_for().
Each inner wrapper_lock destructor calls unlock() — guards are released in reverse order (innermost first).
| void scl::value_lock< Refer >::lock_for | ( | ) |
Activates guards for every wrapper layer needed to reach Target.
| Target | The desired value type (cv-ref qualified) — must satisfy concepts::convertible_from<Target, Refer>. |
If Target is directly convertible from Refer (identity — no unwrapping required), no guard is acquired. Otherwise locks each layer from the outside in until Target is reached.
Calling lock_for() a second time with the same Target is safe (idempotency is guaranteed by the underlying wrapper_lock).
|
nodiscard |
Returns the stored value at the level matching Target.
| Target | The desired value type (cv-ref qualified) — must satisfy concepts::convertible_from<Target, Refer>. |
lock_for<Target>() must have been called beforehand for any wrapper layer that guards the requested value.If Target is directly convertible from Refer, returns the outermost reference without going deeper. Otherwise delegates recursively to the inner value_lock.