Collection of memory chunks for scalable allocation. More...
#include <chunks.hpp>
Public Member Functions | |
| chunks (ncnt blkbyte=0) | |
| chunk & | operator[] (nidx n) |
| const chunk & | operator[] (nidx n) const BY_CONST_FUNC(operator[](n)) |
| chunk & | operator[] (const instance &it) |
| const chunk & | operator[] (const instance &it) const BY_CONST_FUNC(operator[](it)) |
| chunk * | get (nidx n) |
| chunk * | get (const instance &it) |
| chunk * | get (const instance *it) BY_SIDE_FUNC(get) |
| const chunk * | get (nidx n) const BY_CONST_FUNC(get(n)) const chunk *get(const instance &it) const BY_CONST_FUNC(get(it)) const chunk *get(const instance *it) const BY_CONST_FUNC(get(it)) void *new 1() override |
| nbool | del (void *pt, ncnt sz) override |
| virtual nbool | resize (ncnt new1) |
| nbool | has (const instance &it) const override |
| Checks if any of the managed chunks contain the memory allocated for the given instance. | |
| ncnt | len () const override |
| ncnt | size () const override |
| nbool | rel () override |
Public Member Functions inherited from by::allocator | |
| allocator (ncnt blksize=1) | |
| virtual void * | new1 ()=0 |
| 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 |
Additional Inherited Members |
Collection of memory chunks for scalable allocation.
Manages multiple chunk instances. Since chunk uses only fixed-size memory created at initialization, chunks adds/removes multiple chunks to manage memory dynamically.
Since chunks adds or removes chunks, and each chunk cell uses only fixed size, chunks can also only allocate fixed-size memory.
The first to receive memory requests is pool class. When pool receives a memory size to allocate, it lazily retrieves a chunks instance capable of handling that memory size and requests new1(). chunks::new1() finds a chunk capable of allocating memory, and if none exists, creates an additional chunk.
The most recently memory-allocated chunk has the highest probability of being able to allocate additionally. Member variable _s holds the index of the most recently allocated chunk. If _chunks[_s] has no available memory, increment _s. Like a circular array, _chunks' end connects to its beginning. If _s loops back to its pre-traversal value and still no available memory exists, the entire chunks has no available memory, so enters resize().
Implements by::allocator.
Checks if any of the managed chunks contain the memory allocated for the given instance.
| it | The instance whose memory location is to be checked. |
Implements by::memoryHaver.
|
overridevirtual |
Implements by::memoryHaver.
|
overridevirtual |
Implements by::memoryHaver.
|
overridevirtual |
Implements by::memoryHaver.