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 |
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.
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.
watcher uses this value to retrieve the tagN-th life object from its array.
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.
| nbool by::id::isHeap | ( | ) | const |
Checks if the instance identified by this ID is allocated on the heap.