![]() |
Gaia-ECS v1.0.0
A simple and powerful entity component system
|
Fixed-capacity page of equal-sized blocks. More...
#include <paged_allocator.h>
Inheritance diagram for gaia::mem::MemoryPage< T, RequestedBlockSize >:Public Types | |
| using | Page = MemoryPage< T, RequestedBlockSize > |
| This page type. | |
| using | BlockArray = cnt::sarray< uint8_t, BlockArrayBytes > |
| Packed block-index storage. | |
| using | BitView = core::bit_view< NBlocks_Bits > |
| View used to read and write packed block indices. | |
Public Member Functions | |
| MemoryPage (void *ptr) | |
| Free bits to use in the future. | |
| void | write_block_idx (uint32_t blockIdx, uint32_t value) |
| Writes one link in the packed recycled-block list. | |
| uint8_t | read_block_idx (uint32_t blockIdx) const |
| Reads one link from the packed recycled-block list. | |
| GAIA_NODISCARD void * | alloc_block () |
| Allocate a new block for this page. | |
| void | free_block (void *pBlock) |
| Release the block allocated by this page. | |
| GAIA_NODISCARD uint32_t | used_blocks_cnt () const |
| Returns the number of live blocks. | |
| GAIA_NODISCARD bool | full () const |
| Reports whether all page blocks are allocated. | |
| GAIA_NODISCARD bool | empty () const |
| Reports whether no page blocks are allocated. | |
| void | verify () const |
| Verifies page invariants in assertion-enabled builds. | |
Public Member Functions inherited from gaia::mem::MemoryPageHeader | |
| MemoryPageHeader (void *ptr) | |
| Creates a page header for a backing allocation. | |
Public Member Functions inherited from gaia::cnt::fwd_llist_base< MemoryPage< T, RequestedBlockSize > > | |
| fwd_llist_link< MemoryPage< T, RequestedBlockSize > > & | get_fwd_llist_link () |
| Returns the mutable intrusive link. | |
| const fwd_llist_link< MemoryPage< T, RequestedBlockSize > > & | get_fwd_llist_link () const |
| Returns the immutable intrusive link. | |
Static Public Member Functions | |
| static constexpr uint32_t | next_multiple_of_alignment (uint32_t num) |
| Rounds a size up to MemoryBlockAlignment. | |
| static constexpr uint32_t | calculate_block_size () |
| Selects and aligns the configured block size. | |
Public Attributes | |
| BlockArray | m_blocks |
| Implicit list of blocks. | |
| uint32_t | m_blockCnt: NBlocks_Bits |
| Number of blocks in the block array. | |
| uint32_t | m_usedBlocks: NBlocks_Bits |
| Number of used blocks out of NBlocks. | |
| uint32_t | m_nextFreeBlock: NBlocks_Bits |
| Index of the next block to recycle. | |
| uint32_t | m_freeBlocks: NBlocks_Bits |
| Number of blocks to recycle. | |
Public Attributes inherited from gaia::mem::MemoryPageHeader | |
| void * | m_data |
| Pointer to data managed by page. | |
Public Attributes inherited from gaia::cnt::fwd_llist_base< MemoryPage< T, RequestedBlockSize > > | |
| fwd_llist_link< MemoryPage< T, RequestedBlockSize > > | fwd_link_GAIA |
| Intrusive link storage used by fwd_llist. | |
Static Public Attributes | |
| static constexpr uint32_t | MemoryBlockBytes = calculate_block_size() |
| Size of one block in bytes. | |
| static constexpr uint16_t | NBlocks = 48 |
| Maximum number of blocks in a page. | |
| static constexpr uint16_t | NBlocks_Bits = (uint16_t)core::count_bits(NBlocks) |
| Bits required to encode a block index. | |
| static constexpr uint32_t | InvalidBlockId = NBlocks + 1 |
| Sentinel terminating the recycled-block list. | |
| static constexpr uint32_t | BlockArrayBytes = ((uint32_t)NBlocks_Bits * (uint32_t)NBlocks + 7) / 8 |
| Bytes occupied by the packed block-index array. | |
Fixed-capacity page of equal-sized blocks.
| T | Allocation category used for singleton separation and diagnostics. |
| RequestedBlockSize | Requested bytes per block, or zero for the default. |
|
inline |
Free bits to use in the future.
Creates an empty page over a backing allocation.
| ptr | Backing allocation address. |
|
inline |
Allocate a new block for this page.
|
inlinestaticconstexpr |
Selects and aligns the configured block size.
|
inline |
Reports whether no page blocks are allocated.
|
inline |
Release the block allocated by this page.
| pBlock | Pointer previously returned by alloc_block(). |
|
inline |
Reports whether all page blocks are allocated.
|
inlinestaticconstexpr |
Rounds a size up to MemoryBlockAlignment.
| num | Size in bytes. |
|
inline |
Reads one link from the packed recycled-block list.
| blockIdx | Block whose link is read. |
|
inline |
Returns the number of live blocks.
|
inline |
Writes one link in the packed recycled-block list.
| blockIdx | Block whose link is updated. |
| value | Linked block index or InvalidBlockId. |