|
Relational NT
A relational database kernel shaped around NT-style object management.
|
Manages runtime lifecycle concerns for registry objects. More...
#include <LifecycleManager.h>
Public Member Functions | |
| LifecycleManager (ObjectManager &objects, IStorageBackend &storage) | |
| Constructs a LifecycleManager bound to a registry and store. | |
| void | Monitor (ObjectManager::registry *object) |
| Starts monitoring an object's lifecycle. | |
| void | Unmonitor (ObjectManager::registry *object) |
| Stops monitoring an object. | |
| void | Pin (ObjectManager::registry *object) |
| Increments the structural dependency count on an object. | |
| void | Unpin (ObjectManager::registry *object) |
| Decrements the structural dependency count on an object. | |
| bool | IsEligibleForGC (ObjectManager::registry *object) const |
| Returns true when the object is GC-eligible right now. | |
| bool | Collect (ObjectManager::registry *object) |
| Forces a GC attempt on an object without decrementing a counter. | |
| const bool | Contention (ObjectManager::registry *object) |
| Serializes contention for changes to mutable reference states. | |
Manages runtime lifecycle concerns for registry objects.
Object lifetime is governed by two independent counters in registry_head: handle_count (sessions holding an open handle) and reference_count (structural dependencies such as cursors pinned to a snapshot or ephemeral relations referencing their base relations). An object is eligible for GC only when both reach zero.
Monitor / Unmonitor manage handle_count. Pin / Unpin manage reference_count. See docs/reactos-ob-comparison.md §1.
| nt::LifecycleManager::LifecycleManager | ( | ObjectManager & | objects, |
| IStorageBackend & | storage ) |
Constructs a LifecycleManager bound to a registry and store.
Needs the registry to perform GC: Unmonitor and Unpin call ObjectManager::Unregister once both counters reach zero. Type-specific cleanup (e.g. cascading a Multigroup's pin to its child Relations, or a BranchTree's pin to its child Multigroups) runs inside the lifecycle manager before the entry is spliced out. The storage backend is needed by CascadeBranchTree to page the merkle nodes.
| bool nt::LifecycleManager::Collect | ( | ObjectManager::registry * | object | ) |
Forces a GC attempt on an object without decrementing a counter.
Runs the same eligibility check, type-specific cascade, and Unregister as Unmonitor / Unpin, but is callable directly. No-op when the object is still referenced (either counter non-zero) or is a named-lifetime type (BRANCH / SESSION).
Used by the session-close path to collect scratch ephemerals that were never session-pinned and whose consuming cursor has already closed, and (later) by the idle reaper to sweep named entries after Unpinning their session-ownership pin.
| object | Object to attempt to collect. |
| const bool nt::LifecycleManager::Contention | ( | ObjectManager::registry * | object | ) |
Serializes contention for changes to mutable reference states.
Immutable objects — relation snapshots, multigroup snapshots, transactions — never raise contention. Two sessions opening the same immutable snapshot simultaneously is always safe; they will produce independent results without conflict.
Contention applies only to mutable reference states: the HEAD of a branch and namespace entries targeted by atomic multi-reference updates. These are the sole mutable pointers in the system. When a session holds a write handle on a HEAD, a second write opener must block or fail.
| object | Object to check for contention. |
| bool nt::LifecycleManager::IsEligibleForGC | ( | ObjectManager::registry * | object | ) | const |
Returns true when the object is GC-eligible right now.
Eligibility is the joint condition handle_count == 0 && reference_count == 0. Decrement callers (Unmonitor / Unpin) consult this and, when true, run type-specific cleanup before unregistering.
| void nt::LifecycleManager::Monitor | ( | ObjectManager::registry * | object | ) |
Starts monitoring an object's lifecycle.
Increments handle_count on the object's registry_head. Should be called after all authorization checks pass inside HandlerManager::Open.
| object | Object to monitor. |
| void nt::LifecycleManager::Pin | ( | ObjectManager::registry * | object | ) |
Increments the structural dependency count on an object.
Call when one object takes a dependency on another — for example when a cursor pins an immutable snapshot version, or when an ephemeral relation is registered against its base relations. Prevents GC of the target object while the dependency is live.
| object | Object being depended upon. |
| void nt::LifecycleManager::Unmonitor | ( | ObjectManager::registry * | object | ) |
Stops monitoring an object.
Decrements handle_count. When both handle_count and reference_count reach zero, the object becomes eligible for GC.
| object | Object to stop monitoring. |
| void nt::LifecycleManager::Unpin | ( | ObjectManager::registry * | object | ) |
Decrements the structural dependency count on an object.
The inverse of Pin. When both reference_count and handle_count reach zero the object becomes eligible for GC.
| object | Object whose dependency is being released. |