morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
graph.hpp File Reference

The reactive graph's internals: node colours and links, the tracking frame, batching and the flush queue. More...

#include <algorithm>
#include <array>
#include <atomic>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iterator>
#include <memory>
#include <optional>
#include <ranges>
#include <span>
#include <tuple>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>
#include "../../attributes.hpp"
#include "../../core/detail/owner_affinity.hpp"
#include "../../core/detail/owner_probe.hpp"
#include "../../core/executor.hpp"

Go to the source code of this file.

Classes

struct  morph::reactive::detail::EqualityUsable< T >
 Whether == is usable for T: declared, and its element types usable too. More...
struct  morph::reactive::detail::EqualityUsable< T >
 A range is usable when it declares == and its element type is usable. A range whose element is itself (std::filesystem::path) is checked as a plain type. More...
struct  morph::reactive::detail::EqualityUsable< std::optional< T > >
 An optional is usable when its value type is. More...
struct  morph::reactive::detail::EqualityUsable< std::pair< First, Second > >
 A pair is usable when both its types are. More...
struct  morph::reactive::detail::EqualityUsable< std::tuple< Ts... > >
 A tuple is usable when every element type is. More...
struct  morph::reactive::detail::EqualityUsable< std::variant< Ts... > >
 A variant is usable when every alternative is. More...
struct  morph::reactive::detail::FlushBounds
 The bounds a flush keeps, as RuntimeOptions sets them. More...
class  morph::reactive::detail::RuntimeCore
 State shared by one Runtime and every node made from it. More...
class  morph::reactive::detail::TrackingFrame
 Collects the sources one tracked run reads, and restores the previous frame when it ends. More...
class  morph::reactive::detail::Node
 A graph node: a source (Signal), an observer (Effect), or both (Computed). More...
class  morph::reactive::detail::BatchScope
 Opens a batch for its lifetime. More...
class  morph::reactive::detail::WidgetEventScope
 Marks a widget callback for its lifetime. More...

Namespaces

namespace  morph::reactive::detail::site
 The site names a misuse is reported under through exec::detail::noteOwner.

Enumerations

enum class  morph::reactive::detail::Colour : std::uint8_t { Clean , Check , Dirty }
 A node's freshness. Ordered: a later enumerator is staler. More...

Functions

bool morph::reactive::detail::runsLater (Node const *lhs, Node const *rhs) noexcept
 The flush queue's heap order: the node that runs first is on top.

Variables

constexpr char const * morph::reactive::detail::site::kOffOwner = "morph::reactive: off the Runtime's owner"
 An operation ran off the Runtime's owner; it is dropped.
constexpr char const * morph::reactive::detail::site::kEffectThrew = "morph::reactive: an exception escaped an Effect"
 An exception escaped an Effect; the flush stops.
constexpr char const * morph::reactive::detail::site::kWriteCycle = "morph::reactive: an Effect re-ran past maxEffectRunsPerFlush"
 An Effect re-ran more than maxEffectRunsPerFlush times in one flush; the flush stops.
constexpr char const * morph::reactive::detail::site::kSetInComputed = "morph::reactive: set() inside a Computed"
 A signal was written while a Computed was computing; the write is dropped.
constexpr char const * morph::reactive::detail::site::kComputedReadsItself = "morph::reactive: a Computed read itself"
 A Computed read itself; the read throws std::logic_error.
constexpr char const * morph::reactive::detail::site::kSendInUpdate = "morph::reactive: send() inside an update"
 Store::send was called from inside an update; the message is dropped.
constexpr char const * morph::reactive::detail::site::kIssueInComputed
 Query::refetch or Mutation::run was called while a Computed was computing; nothing is issued.
constexpr char const * morph::reactive::detail::site::kAfterFlushThrew = "morph::reactive: an exception escaped afterFlush"
 An exception escaped RuntimeOptions::afterFlush; it is dropped.
constexpr char const * morph::reactive::detail::site::kRuntimeOutlived = "morph::reactive: Runtime destroyed while nodes are alive"
 A Runtime was destroyed while nodes made from it were alive.
constexpr char const * morph::reactive::detail::site::kHandlerExecutor = "morph::reactive: a handler delivers off the Runtime's owner"
 A control node was built over a handler whose callbacks are not delivered on the Runtime's owner.
constexpr std::size_t morph::reactive::detail::kDefaultMaxEffectRunsPerFlush = 100
 How many times one Effect may run in a single flush unless RuntimeOptions says otherwise.
constexpr std::size_t morph::reactive::detail::kDefaultMaxThrowReposts = 3
 How many flushes in a row are re-posted after an Effect threw, unless RuntimeOptions says otherwise.
constexpr std::size_t morph::reactive::detail::kRecentMisuses = 16
 How many of the latest misuses a runtime keeps the site of.

Detailed Description

The reactive graph's internals: node colours and links, the tracking frame, batching and the flush queue.

Specified in docs/spec/reactive/signals.md.

Definition in file graph.hpp.

Enumeration Type Documentation

◆ Colour

enum class morph::reactive::detail::Colour : std::uint8_t
strong

A node's freshness. Ordered: a later enumerator is staler.

Enumerator
Clean 

Up to date.

Check 

A transitive source changed: pull the sources before deciding to recompute.

Dirty 

A direct source changed: recompute.

Definition at line 121 of file graph.hpp.

Function Documentation

◆ runsLater()

bool morph::reactive::detail::runsLater ( Node const * lhs,
Node const * rhs )
inlinenoexcept

The flush queue's heap order: the node that runs first is on top.

Parameters
lhsA queued node.
rhsAnother queued node.
Returns
Whether lhs runs after rhs.

Definition at line 735 of file graph.hpp.

Variable Documentation

◆ kDefaultMaxEffectRunsPerFlush

std::size_t morph::reactive::detail::kDefaultMaxEffectRunsPerFlush = 100
inlineconstexpr

How many times one Effect may run in a single flush unless RuntimeOptions says otherwise.

Definition at line 61 of file graph.hpp.

◆ kDefaultMaxThrowReposts

std::size_t morph::reactive::detail::kDefaultMaxThrowReposts = 3
inlineconstexpr

How many flushes in a row are re-posted after an Effect threw, unless RuntimeOptions says otherwise.

Definition at line 64 of file graph.hpp.

◆ kRecentMisuses

std::size_t morph::reactive::detail::kRecentMisuses = 16
inlineconstexpr

How many of the latest misuses a runtime keeps the site of.

Definition at line 67 of file graph.hpp.