Skip to content

Refactor: Handle node cleanup #12

@GuilhermeF03

Description

@GuilhermeF03

Problem

Right now the node system is composed of multiple components::

  • Nodes
  • Behaviors
  • Tree Systems

We also have our flow system with Contexts, Signals, Events, Effects

Each of them can reference nodes is some way or another:

  • Tree Systems hold a list of processable nodes that match its types criteria
  • Events can hold a callback listener created by a node (Contexts and Signals also apply).

GC Behavior

As of today, removing any node from the tree has an unpredictable cascading effect on each of these systems. Due to the JVM GC's algorithm, references which are strongly referenced can't be collected, while weak references can. We can use Java Weak References classes to achieve this.

This means that:

  • We want weak references where the object making the reference is an optional referrer.

Signals
Signals hold a list of weak referenced callbacks - we need a way to make sure this callback gets removed as soon as a Node is removed.

Tree Systems
Tree systems hold a list of processable nodes, based on type-based filters. We need to make sure that when a node is removed, it gets removed from the list as well.

Other cases
Some other cases may be discovered, and should be discussed as well with the rest of the team.

Note

Some work was done by GPT, but hasn't been reviewed in some time and may be outdated.


Guidelines

  • Tight coupling Node to other systems is strictly forbbiden - Node should remain as atomic as possible. It doesn't need to know about Tree Sytems nor reactive systems.
  • Cleanup should automatically cascade discussed behaviors.

Metadata

Metadata

Assignees

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions