|
Toast Engine
|
Reference-count control block embedded inside the Node allocation. More...
#include <control_box.hpp>

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 | |
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>.
|
nodiscardnoexcept |
Stable numeric identity for this ControlBox.
