← API Reference Class

template<typename T> asge::concurrent::ContextWithValue

A context that carries an immutable typed value alongside cancellation.

#include <Context.hpp>

Inherits from asge::concurrent::Context.

Inheritance

classDiagram
    class N2["asge::concurrent::Context"]
    class N1["asge::concurrent::ContextWithValue"]
    class N3["asge::concurrent::_internal::IContext"]
    class N4["std::enable_shared_from_this"]
    N3 <|-- N2
    N4 <|-- N2
    N2 <|-- N1
    click N2 href "classasge_1_1concurrent_1_1Context.html"
    click N1 href "classasge_1_1concurrent_1_1ContextWithValue.html"
    click N3 href "structasge_1_1concurrent_1_1__internal_1_1IContext.html"

Collaboration

classDiagram
    class N2["asge::concurrent::Context"]
    class N1["asge::concurrent::ContextWithValue"]
    class N5["asge::concurrent::_internal::CancelState"]
    class N3["asge::concurrent::_internal::IContext"]
    class N4["std::enable_shared_from_this"]
    N3 <|-- N2
    N4 <|-- N2
    N2 --> N5 : m_State
    N2 <|-- N1
    click N2 href "classasge_1_1concurrent_1_1Context.html"
    click N1 href "classasge_1_1concurrent_1_1ContextWithValue.html"
    click N5 href "structasge_1_1concurrent_1_1__internal_1_1CancelState.html"
    click N3 href "structasge_1_1concurrent_1_1__internal_1_1IContext.html"

ContextWithValue extends Context with a single value of type T that is set at construction and never changes. It inherits the full cancellation and tree propagation behaviour of Context — cancelling it behaves identically to cancelling a plain Context.

Created exclusively through WithValue(), never constructed directly.

Template Parameters
T

Type of the value carried by this context. Must be move-constructible.

Public Types

#using value_type = T
#using const_reference = T const &
#using pointer = std::shared_ptr< ContextWithValue< T > >

Private Attributes

#T m_Valueprivate

Private Member Functions

#explicit ContextWithValue(context_pointer inParent, T inValue)private

Public Member Functions

#const_reference Value() const noexcept

Friends

#friend WithValue

Derives a child context that carries an immutable typed value.

Creates a new ContextWithValue<T> as a child of the given parent, attaching it to the context tree. If the parent is already cancelled at the time of this call, the child is cancelled immediately with the same error. Otherwise the child is registered with the parent and will be cancelled automatically when the parent is.

Template Parameters
T

Type of the value to carry. Must be move-constructible.

Parameters
inValue

The value to attach to the context.

inParent

The parent context (nullptr by default).