EasyNav Plugins
Loading...
Searching...
No Matches
GridBlockAllocator< DataT > Class Template Reference

The GridBlockAllocator is used to pre-allocate the meory of multiple Grids in "chunks". More...

#include <grid_allocator.hpp>

Collaboration diagram for GridBlockAllocator< DataT >:

Classes

struct  Chunk

Public Types

using Deleter = std::function<void()>

Public Member Functions

std::pair< DataT *, DeleterallocateBlock ()
size_t capacity () const
void clear ()
 GridBlockAllocator (const GridBlockAllocator &)=delete
 GridBlockAllocator (GridBlockAllocator &&)=default
 GridBlockAllocator (size_t log2dim)
size_t memUsage () const
GridBlockAllocatoroperator= (const GridBlockAllocator &other)=delete
GridBlockAllocatoroperator= (GridBlockAllocator &&other)=default
void releaseUnusedMemory ()
size_t size () const

Static Public Attributes

static constexpr size_t blocks_per_chunk = 512

Protected Member Functions

void addNewChunk ()
Deleter createDeleter (std::shared_ptr< Chunk > chunk, uint32_t index)

Protected Attributes

size_t block_bytes_ = 0
size_t capacity_ = 0
std::vector< std::shared_ptr< Chunk > > chunks_
size_t log2dim_ = 0
std::unique_ptr< std::mutex > mutex_
size_t size_ = 0

Detailed Description

template<typename DataT>
class Bonxai::GridBlockAllocator< DataT >

The GridBlockAllocator is used to pre-allocate the meory of multiple Grids in "chunks".

It is a very simple memory pool.

Each chunk allocates memory for 512 Grids

Member Typedef Documentation

◆ Deleter

template<typename DataT>
using Deleter = std::function<void()>

Constructor & Destructor Documentation

◆ GridBlockAllocator() [1/3]

template<typename DataT>
GridBlockAllocator ( size_t log2dim)

◆ GridBlockAllocator() [2/3]

template<typename DataT>
GridBlockAllocator ( const GridBlockAllocator< DataT > & )
delete

◆ GridBlockAllocator() [3/3]

template<typename DataT>
GridBlockAllocator ( GridBlockAllocator< DataT > && )
default

Member Function Documentation

◆ addNewChunk()

template<typename DataT>
void addNewChunk ( )
protected

◆ allocateBlock()

template<typename DataT>
std::pair< DataT *, typename GridBlockAllocator< DataT >::Deleter > allocateBlock ( )

◆ capacity()

template<typename DataT>
size_t capacity ( ) const

◆ clear()

template<typename DataT>
void clear ( )

◆ createDeleter()

template<typename DataT>
GridBlockAllocator< DataT >::Deleter createDeleter ( std::shared_ptr< Chunk > chunk,
uint32_t index )
protected

◆ memUsage()

template<typename DataT>
size_t memUsage ( ) const

◆ operator=() [1/2]

template<typename DataT>
GridBlockAllocator & operator= ( const GridBlockAllocator< DataT > & other)
delete

◆ operator=() [2/2]

template<typename DataT>
GridBlockAllocator & operator= ( GridBlockAllocator< DataT > && other)
default

◆ releaseUnusedMemory()

template<typename DataT>
void releaseUnusedMemory ( )

◆ size()

template<typename DataT>
size_t size ( ) const

Member Data Documentation

◆ block_bytes_

template<typename DataT>
size_t block_bytes_ = 0
protected

◆ blocks_per_chunk

template<typename DataT>
size_t blocks_per_chunk = 512
staticconstexpr

◆ capacity_

template<typename DataT>
size_t capacity_ = 0
protected

◆ chunks_

template<typename DataT>
std::vector<std::shared_ptr<Chunk> > chunks_
protected

◆ log2dim_

template<typename DataT>
size_t log2dim_ = 0
protected

◆ mutex_

template<typename DataT>
std::unique_ptr<std::mutex> mutex_
protected

◆ size_

template<typename DataT>
size_t size_ = 0
protected

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