Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::mem::detail::SmallBlockPage Struct Referencefinal
+ Inheritance diagram for gaia::mem::detail::SmallBlockPage:

Public Types

using BlockArray = cnt::sarray< uint8_t, BlockArrayBytes >
 
using BitView = core::bit_view< NBlocks_Bits >
 

Public Member Functions

 SmallBlockPage (void *ptr, uint8_t sizeType)
 Constructs a page for the given size class.
 
GAIA_NODISCARD uint32_t block_stride () const
 Returns the stride of one block in this page.
 
void write_block_idx (uint32_t blockIdx, uint32_t value)
 
GAIA_NODISCARD uint8_t read_block_idx (uint32_t blockIdx) const
 
GAIA_NODISCARD void * alloc_block ()
 Allocates one block from this page.
 
void free_block (void *pBlock)
 Frees one block back to this page.
 
GAIA_NODISCARD uint32_t used_blocks_cnt () const
 Returns the number of live blocks.
 
GAIA_NODISCARD bool full () const
 Returns true when the page is full.
 
GAIA_NODISCARD bool empty () const
 Returns true when the page is empty.
 
void verify () const
 Verifies internal page invariants.
 
- Public Member Functions inherited from gaia::cnt::fwd_llist_base< SmallBlockPage >
fwd_llist_link< SmallBlockPage > & get_fwd_llist_link ()
 
const fwd_llist_link< SmallBlockPage > & get_fwd_llist_link () const
 

Public Attributes

void * m_data
 
BlockArray m_blocks
 
uint32_t m_sizeType: SizeTypeBits
 
uint32_t m_blockCnt: NBlocks_Bits
 
uint32_t m_usedBlocks: NBlocks_Bits
 
uint32_t m_nextFreeBlock: NBlocks_Bits
 
uint32_t m_freeBlocks: NBlocks_Bits
 
- Public Attributes inherited from gaia::cnt::fwd_llist_base< SmallBlockPage >
fwd_llist_link< SmallBlockPage > fwd_link_GAIA
 

Static Public Attributes

static constexpr uint16_t NBlocks = 64
 
static constexpr uint16_t NBlocks_Bits = (uint16_t)core::count_bits(NBlocks)
 
static constexpr uint16_t SizeTypeBits = (uint16_t)core::count_bits(SmallBlockSizeTypeCount - 1)
 
static constexpr uint32_t InvalidBlockId = NBlocks + 1
 
static constexpr uint32_t BlockArrayBytes = ((uint32_t)NBlocks_Bits * (uint32_t)NBlocks + 7) / 8
 

Constructor & Destructor Documentation

◆ SmallBlockPage()

gaia::mem::detail::SmallBlockPage::SmallBlockPage ( void *  ptr,
uint8_t  sizeType 
)
inline

Constructs a page for the given size class.

Parameters
ptrRaw page data.
sizeTypeSize class index.

Member Function Documentation

◆ alloc_block()

GAIA_NODISCARD void * gaia::mem::detail::SmallBlockPage::alloc_block ( )
inline

Allocates one block from this page.

Returns
Pointer to the usable storage.

◆ free_block()

void gaia::mem::detail::SmallBlockPage::free_block ( void *  pBlock)
inline

Frees one block back to this page.

Parameters
pBlockPointer previously returned by alloc_block().

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