Loading...
Searching...
No Matches
by::id Struct Reference

Unique identifier for instances in memlite system. More...

#include <id.hpp>

Public Member Functions

 id (nint new_tagN, nint newChkN, nuint newSerial)
 
nbool operator== (const id &rhs) const
 
nbool operator!= (const id &rhs) const
 
void rel ()
 Resets the ID to an invalid or default state.
 
nbool isHeap () const
 Checks if the instance identified by this ID is allocated on the heap.
 
nbool isValid () const
 

Public Attributes

nint tagN: 21
 
nint chkN: 22
 
nuint serial: 21
 

Detailed Description

Unique identifier for instances in memlite system.

64-bit integer instance identifier. tagN identifies life, chkN indicates which chunk, and serial is used for object validation.

serial is instance creation count during process execution

As seen from pool and chunk, using a custom memory pool means when memory is released, only the destructor is called without initializing all memory. Previously allocated and destroyed data remains, and accessing this data is even possible. (If accessing used data causes exceptions or UB, implementing binder with weak or strong pointers would be impossible.) binder additionally compares serial to distinguish whether retrieved data is truly valid.

tagN used for accessing life objects

watcher uses this value to retrieve the tagN-th life object from its array.

chkN used for retrieving chunk objects

pool first calculates instance size mapped to id to retrieve chunks. Then chunks returns the memory block at its chkN-th element. Externally, the received memory address and serial value are compared to verify it's the same instance.

Member Function Documentation

◆ isHeap()

nbool by::id::isHeap ( ) const

Checks if the instance identified by this ID is allocated on the heap.

Returns
true if the associated instance is heap-allocated, false otherwise.

The documentation for this struct was generated from the following files: