Loading...
Searching...
No Matches
by::pool Class Reference

Memory pool manager for efficient instance allocation. More...

#include <pool.hpp>

Inheritance diagram for by::pool:
by::memoryHaver

Public Member Functions

chunksget (const instance &it)
 Gets chunks container managing memory for given instance.
 
chunksget (const instance *it) BY_SIDE_FUNC(get)
 
chunksget (nidx n)
 Gets chunks at specified index.
 
ncnt size () const override
 
ncnt len () const override
 
nbool rel () override
 Releases all pool resources and destroys chunks.
 
- Public Member Functions inherited from by::memoryHaver
virtual nbool has (const instance &it) const =0
 Checks if this memory manager "owns" or contains the given instance.
 
nbool has (const instance *it) const BY_SIDE_FUNC(has)
 
nbool isFull () const
 
nbool isCapable () const
 

Public Attributes

const chunks *get(const instance &it) const BY_CONST_FUNC(get(it)) const chunks *get(const instance *it) const BY_CONST_FUNC(get(it)) const chunks *get(nidx n) const BY_CONST_FUNC(get(n)) using super nboo has )(const instance &it) const override
 Checks if instance is managed by this pool.
 

Protected Member Functions

void_get (nidx n) override
 Gets raw memory pointer at index.
 

Detailed Description

Memory pool manager for efficient instance allocation.

The first class to handle memory allocation requests from external sources. Internally has an array of chunks, and since chunks has chunk, effectively manages all low-level memory-related classes.

pool lazily has chunks per allocatable size

A key point in creating a custom memory pool is increasing speed by listing same-size memory in one place. chunks has a block concept where each block can only allocate/ deallocate pre-specified sized memory. pool creates chunks with fixed block size. When external requests memory allocation of a specific size, pool finds chunks handling that block size. If none exist, creates lazily.

Member Function Documentation

◆ _get()

void * by::pool::_get ( nidx n)
overrideprotectedvirtual

Gets raw memory pointer at index.

Returns
Void pointer to memory at index n
Note
Internal accessor for memoryHaver interface

Implements by::memoryHaver.

◆ get() [1/2]

chunks * by::pool::get ( const instance & it)

Gets chunks container managing memory for given instance.

Returns
Pointer to chunks managing this instance's memory, or nullptr if not found
Note
Finds chunks by instance size to locate appropriate memory block

◆ get() [2/2]

chunks * by::pool::get ( nidx n)

Gets chunks at specified index.

Returns
Pointer to chunks at index n, or nullptr if out of bounds

◆ len()

ncnt by::pool::len ( ) const
overridevirtual

Implements by::memoryHaver.

◆ rel()

nbool by::pool::rel ( )
overridevirtual

Releases all pool resources and destroys chunks.

Returns
true on success, false on failure
Note
Destroys all chunks and frees allocated memory

Implements by::memoryHaver.

◆ size()

ncnt by::pool::size ( ) const
overridevirtual

Implements by::memoryHaver.

Member Data Documentation

◆ has

Checks if instance is managed by this pool.

Returns
true if instance allocated from this pool, false otherwise

The documentation for this class was generated from the following file: