Execute a computational graph on demand, publishing immutable results only after the entire request succeeds.
More...
|
| | ComputationCache (GraphT graph, ObserversT observers=ObserversT{}) |
| | Own the graph, observer callbacks, and accepted cache; each preparation borrows its context.
|
| |
| | ComputationCache (const ComputationCache &)=delete |
| |
| ComputationCache & | operator= (const ComputationCache &)=delete |
| |
| | ComputationCache (ComputationCache &&other) |
| | Transfer accepted results while leaving the original object unprepared.
|
| |
| ComputationCache & | operator= (ComputationCache &&)=delete |
| |
template<IsKeyList RequestedT = GraphT::Results>
requires detail::key_list_subset_v<std::remove_cvref_t<RequestedT>, typename GraphT::Results> |
| std::expected< Report, Failure > | try_prepare (const ContextT &context, RequestedT={}, const PreparationMode mode=PreparationMode::reuse_unchanged) |
| | Prepare the requested results and their prerequisites, publishing only a complete successful candidate.
|
| |
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename GraphT::Results> |
| bool | contains () const |
| | Test whether a result belongs to the latest successful request, including its prerequisites.
|
| |
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename GraphT::Results> |
| const auto & | get () const |
| | Read a frozen result. References remain valid until the next preparation or invalidation.
|
| |
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename GraphT::Results> |
| auto | share () const |
| | Retain an immutable accepted result independently of subsequent cache preparations.
|
| |
| const Report & | report () const noexcept |
| | Report reuse and rebuilding from the latest successful preparation.
|
| |
| bool | ready () const noexcept |
| | A failed preparation makes all result access unavailable until a subsequent success.
|
| |
| std::size_t | preparation_count () const noexcept |
| | Count successful preparations, including requests whose results were all reused.
|
| |
| void | clear_preparation () noexcept |
| | Make results unavailable before validating a new candidate's inputs.
|
| |
| void | invalidate () noexcept |
| | Discard accepted snapshots and results, requiring fresh preparation on the next request.
|
| |
|
| template<typename KeyT> |
| void | inspect_source (const ContextT &context, Storage &candidate, Report &report, SourceMask &inspected, const PreparationMode mode) const |
| | Inspect each required source once; other context objects need no snapshot policy.
|
| |
| template<typename KeyT> |
| const auto & | input_value (const ContextT &context, const Storage &candidate) const |
| | Sources and computed prerequisites expose the same read-only values to edge observers.
|
| |
| template<typename ComputationT, typename KeyT> |
| const auto & | input (const ContextT &context, const Storage &candidate) const |
| | Only computed prerequisites have immutable owning handles; ordinary inputs remain references.
|
| |
| template<std::size_t Index, typename... Keys> |
| auto | evaluate_node (const ContextT &context, const Storage &candidate, KeyList< Keys... >) |
| | Execute one node after its inputs are ready and reuse has been ruled out.
|
| |
| template<std::size_t Index, typename... Keys> |
| std::expected< void, Failure > | prepare_one (const ContextT &context, Storage &candidate, Report &report, SourceMask &inspected, const PreparationMode mode, KeyList< Keys... >) |
| | Reuse a result only when every input version matches its accepted version.
|
| |
| template<std::size_t Position> |
| std::expected< void, Failure > | prepare_in_order (const ContextT &context, Storage &candidate, Report &report, SourceMask &inspected, const ResultMask &required, PreparationMode mode) |
| | Follow the compile-time order while skipping branches outside the requested closure.
|
| |
template<typename GraphT, typename ContextT, typename ErrorT = std::string, typename ObserversT = Observers<>>
requires CanPrepare<GraphT, ContextT, ErrorT> && ObserversFor<ObserversT, GraphT, ContextT>
class serif::utils::dependencies::ComputationCache< GraphT, ContextT, ErrorT, ObserversT >
Execute a computational graph on demand, publishing immutable results only after the entire request succeeds.