Toast Engine
Loading...
Searching...
No Matches
toast::_detail::ControlBox Struct Reference

Reference-count control block embedded inside the Node allocation. More...

#include <control_box.hpp>

Collaboration diagram for toast::_detail::ControlBox:

Public Member Functions

 ControlBox (Node *n)
 Initializes ref_count to 1 and stores the node pointer; called by nodeAllocation().
 ControlBox (const ControlBox &)=delete
 ControlBox (ControlBox &&)=delete
auto operator= (const ControlBox &) -> ControlBox &=delete
auto operator= (ControlBox &&) -> ControlBox &=delete
 operator bool () const noexcept
 Returns true when the node pointer is non-null, i.e. the node has not been freed.
auto operator<=> (const ControlBox &other) const noexcept -> std::strong_ordering
 Total order over ControlBox identity; compares by rid() so boxes sort consistently in maps.
auto operator== (const ControlBox &other) const noexcept -> bool
auto rid () const noexcept -> std::uintptr_t
 Stable numeric identity for this ControlBox.
void increment ()
 relaxed acquire; acquiring a Box is always preceded by an acquire elsewhere
void decrement ()
 acq_rel release; ensures the last releaser sees all prior writes before decrementing

Static Public Member Functions

static auto get (const Node *node) -> ControlBox *
 Recovers the ControlBox from a raw node pointer; the ControlBox sits immediately before the Node in memory.
static auto get (const Node &node) -> ControlBox *
 Recovers the ControlBox from a node reference; equivalent to get(&node).

Public Attributes

std::atomic< unsigned int > ref_count
 starts at 1 (the node's self-reference); node is freed when it hits 0
Node * node = nullptr
 null once the node is destroyed

Detailed Description

Reference-count control block embedded inside the Node allocation.

Lives immediately before the Node in a single contiguous heap block so that Box<Node> handles need no separate allocation. ControlBox is an implementation detail; user code should interact exclusively through Box<Node>.

Note
Copy and move are deleted: the ControlBox must never move in memory because all Box handles hold raw pointers to it

Member Function Documentation

◆ rid()

auto toast::_detail::ControlBox::rid ( ) const -> std::uintptr_t
nodiscardnoexcept

Stable numeric identity for this ControlBox.

Returns
The ControlBox address cast to uintptr_t; stable for the lifetime of the node; used as a hash key in the dependency graph maps
Here is the caller graph for this function:

The documentation for this struct was generated from the following files:
  • engine/src/toast/world/control_box.hpp
  • engine/src/toast/world/control_box.cpp