"ScL Feature"/
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Loading...
Searching...
No Matches
scl::value_lock< Refer > Class Template Reference

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.

Detailed Description

template<typename Refer>
class scl::value_lock< Refer >

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.

Template Parameters
ReferReference type — either wrapper<V,E> cv-ref or a plain value cv-ref.
value_lock<decltype(ww) &> vl{ww};
vl.lock_for<int &>(); // locks both B and A executors
int & v = vl.value_as<int &>(); // safe: both guards held
Recursive lazy RAII lock through a wrapper chain.
Definition value_lock.h:45
void lock_for()
Activates guards for every wrapper layer needed to reach Target.
Composable proxy wrapper that delegates to Value through executors.
Definition wrapper.h:72

Constructor & Destructor Documentation

◆ value_lock()

template<typename Refer>
scl::value_lock< Refer >::value_lock ( Refer ref)
explicit

Constructs the lock, capturing references to every executor in the wrapper chain. No guard is acquired at construction.

Parameters
refReference to the outermost wrapper or plain value.

◆ ~value_lock()

template<typename Refer>
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).

Member Function Documentation

◆ lock_for()

template<typename Refer>
template<typename Target>
requires ::scl::feature::concepts::convertible_from<Target, Refer>
void scl::value_lock< Refer >::lock_for ( )

Activates guards for every wrapper layer needed to reach Target.

Template Parameters
TargetThe 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).

◆ value_as()

template<typename Refer>
template<typename Target>
requires ::scl::feature::concepts::convertible_from<Target, Refer>
Target scl::value_lock< Refer >::value_as ( )
nodiscard

Returns the stored value at the level matching Target.

Template Parameters
TargetThe desired value type (cv-ref qualified) — must satisfy concepts::convertible_from<Target, Refer>.
Precondition
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.


The documentation for this class was generated from the following file: