Memory watcher for tracking instance lifecycle and allocation. More...
#include <watcher.hpp>
Public Member Functions | |
| life & | operator[] (nidx n) |
| const life & | operator[] (nidx n) const BY_CONST_FUNC(operator[](n)) |
| life & | operator[] (id id) |
| const life & | operator[] (id id) const BY_CONST_FUNC(operator[](id)) |
| life * | get (nidx n) |
| life * | get (id newId) |
| const life * | get (nidx n) const BY_CONST_FUNC(get(n)) const life *get(id new Id) const BY_CONST_FUNC(get(newId)) void *new 1() override |
| Allocates new life object from pre-allocated chunk. | |
| nbool | del (void *used, ncnt sz) override |
| Returns life object back to available pool. | |
Public Member Functions inherited from by::chunk | |
| chunk (ncnt blockSz=1, ncnt sz=MIN_SZ) | |
| void * | operator[] (nidx n) |
| const void * | operator[] (nidx n) const BY_CONST_FUNC(operator[](n)) |
| void * | get (nidx n) |
| void * | new1 () override |
| ncnt | len () const override |
| ncnt | size () const override |
| nbool | rel () override |
| nbool | has (const instance &it) const override |
| Checks if this chunk contains the memory allocated for the given instance. | |
Public Member Functions inherited from by::allocator | |
| allocator (ncnt blksize=1) | |
| ncnt | getBlkSize () const |
Public Member Functions inherited from by::memoryHaver | |
| nbool | has (const instance *it) const BY_SIDE_FUNC(has) |
| nbool | isFull () const |
| nbool | isCapable () const |
Protected Member Functions | |
| id | _genId (void *pt) const |
| Generates unique id for instance pointer. | |
| nidx | _getIdx (void *it) const |
| Calculates index in chunk from pointer address. | |
Protected Member Functions inherited from by::chunk | |
| void * | _get (nidx n) override |
| nuchar * | _getHeap () |
| const nuchar * | _getHeap () const BY_CONST_FUNC(_getHeap()) nbool _resize(ncnt new Sz) |
Additional Inherited Members | |
Static Public Attributes inherited from by::chunk | |
| static constexpr ncnt | MIN_SZ = 20 |
Memory watcher for tracking instance lifecycle and allocation.
One pillar of memory management that manages created object lifecycles. Whenever an instance is created, watcher additionally allocates a life object and uses reference counting to determine object destruction timing.
When binder binds an instance, life increments its strong count by 1. When binder calls rel() on instance, decrements count by 1. At 0, deletes from memory. instance uses operator delete() to make instancer execute memory release work.
Generates unique id for instance pointer.
Calculates index in chunk from pointer address.
Returns life object back to available pool.
Reimplemented from by::chunk.
Allocates new life object from pre-allocated chunk.