Skip to content

Observer and Observed

Lszaboo edited this page Nov 9, 2025 · 5 revisions

Resource management

Since the Dependency graph decides what happens when a User input happened, the management of updating the resources, such as the GPU, resource managemnt is built into the graph for efficient safe and automatic update pipeline.

Let's look at the example below:

DependencyGraph04

On the picture above we can see that some nodes have assigned Resource managers called pointObserver and crvObserver.

The callstack will look like that, where the function will immidetaly call the function on the right, pointed to by a pink arrow.

Observer

Observers will serve the roles of resource managers, who manage many nodes (Observed) in the graph. Theese classes are part of the Dependency graph but not in the same sense, as normal Dependents.

Functions

added!

The added! function is called, whenever an Observed is assigned to this instance of the Observer.

sync!

The sync! function is called, whenever an Observed which is managed by this instance of an Observer is updated, evaluated in the Dependency graph.

In a correct Observer - Observed object pair implementation, the following Invariants have to be provided for the sync! function:

  1. Correct total call count, so sync! is called as many times for an Observer, as there are Observed managed by this Observer reachable from the source node. If the source node is managed by this Observer, it should be synced too.
  2. Correct Observed called only, so only the Observed which are reachable from the source node are called, others which are not reachable but managed by the Observer can't be called (because they are no updated). If the source node is managed by this Observer, it should be synced too.

syncAll!

The syncAll! function is called, whenever Observer had Observed which have been updated during a Dependency graph evaluation.

In a correct Observer - Observed object pair implementation, the following Invariants is provided for the syncAll! function:

  1. Call only when reachable, so If any Observed managed by this Observer was reachable from the source node, or the source node was managed by this Observer, a syncAll! call should happen to this Observer.

Observed

The Observed inherit from the Dependent class, so they are essentially nodes in the Dependency graph.

They also have an Observer assigned to them.

Wiki navigation sidebar

Legend:

  • ✅: Up-to-date
  • 🏗️: Needs some work
  • ❌: Unusable
  1. 🏗️ Home
  2. 🏗️ Developer Guide
    1. Composition Subclassing
    2. Core Graph
    3. 🏗️ Dependents
    4. 🏗️ Observer and Observed
    5. 🏗️ Plans
    6. 🏗️ Rendered Dependents
    7. Macro Constructors

Clone this wiki locally