-
Notifications
You must be signed in to change notification settings - Fork 0
Observer and Observed
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:
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.
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.
The added! function is called, whenever an Observed is assigned to this instance of the Observer.
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:
-
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. - 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.
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:
- 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.
The Observed inherit from the Dependent class, so they are essentially nodes in the Dependency graph.
They also have an Observer assigned to them.