LMMS
Loading...
Searching...
No Matches
zyncarla::Allocator Class Referenceabstract

#include <Allocator.h>

Inheritance diagram for zyncarla::Allocator:
zyncarla::AllocatorClass zyncarla::DummyAllocator

Public Member Functions

 Allocator (void)
 Allocator (const Allocator &)=delete
virtual ~Allocator (void)
virtual voidalloc_mem (size_t mem_size)=0
virtual void dealloc_mem (void *memory)=0
template<typename T, typename... Ts>
T * alloc (Ts &&... ts)
template<typename T, typename... Ts>
T * valloc (size_t len, Ts &&... ts)
template<typename T>
void dealloc (T *&t)
template<typename T>
void devalloc (T *&t)
template<typename T>
void devalloc (size_t elms, T *&t)
void beginTransaction ()
void endTransaction ()
virtual void addMemory (void *, size_t mem_size)=0
virtual bool lowMemory (unsigned n, size_t chunk_size) const =0
bool memFree (void *pool) const
int memPools () const
int freePools () const
unsigned long long totalAlloced () const

Public Attributes

struct AllocatorImplimpl

Private Member Functions

void rollbackTransaction ()
void append_alloc_to_memory_transaction (void *new_memory)

Private Attributes

voidtransaction_alloc_content [max_transaction_length]
size_t transaction_alloc_index
bool transaction_active

Static Private Attributes

static const size_t max_transaction_length = 256

Detailed Description

Allocator Base class subclasses must specify allocation and deallocation

Constructor & Destructor Documentation

◆ Allocator() [1/2]

zyncarla::Allocator::Allocator ( void )

◆ Allocator() [2/2]

zyncarla::Allocator::Allocator ( const Allocator & )
delete

◆ ~Allocator()

zyncarla::Allocator::~Allocator ( void )
virtual

Member Function Documentation

◆ addMemory()

virtual void zyncarla::Allocator::addMemory ( void * ,
size_t mem_size )
pure virtual

◆ alloc()

template<typename T, typename... Ts>
T * zyncarla::Allocator::alloc ( Ts &&... ts)
inline

High level allocator method, which return a pointer to a class or struct allocated with the specialized subclass strategy

Parameters
tsargument(s) for the constructor of the type T
Returns
a non null pointer to a new object of type T
Exceptions
std::bad_allocis no memory could be allocated

◆ alloc_mem()

virtual void * zyncarla::Allocator::alloc_mem ( size_t mem_size)
pure virtual

◆ append_alloc_to_memory_transaction()

void zyncarla::Allocator::append_alloc_to_memory_transaction ( void * new_memory)
inlineprivate

Append memory block to the list of memory blocks allocated during this transaction

Parameters
new_memorypointer to the memory pointer to freshly allocated

◆ beginTransaction()

void zyncarla::Allocator::beginTransaction ( )

◆ dealloc()

template<typename T>
void zyncarla::Allocator::dealloc ( T *& t)
inline

◆ dealloc_mem()

virtual void zyncarla::Allocator::dealloc_mem ( void * memory)
pure virtual

◆ devalloc() [1/2]

template<typename T>
void zyncarla::Allocator::devalloc ( size_t elms,
T *& t )
inline

◆ devalloc() [2/2]

template<typename T>
void zyncarla::Allocator::devalloc ( T *& t)
inline

◆ endTransaction()

void zyncarla::Allocator::endTransaction ( )

◆ freePools()

int zyncarla::Allocator::freePools ( ) const

◆ lowMemory()

virtual bool zyncarla::Allocator::lowMemory ( unsigned n,
size_t chunk_size ) const
pure virtual

◆ memFree()

bool zyncarla::Allocator::memFree ( void * pool) const

◆ memPools()

int zyncarla::Allocator::memPools ( ) const

◆ rollbackTransaction()

void zyncarla::Allocator::rollbackTransaction ( )
private

◆ totalAlloced()

unsigned long long zyncarla::Allocator::totalAlloced ( ) const

◆ valloc()

template<typename T, typename... Ts>
T * zyncarla::Allocator::valloc ( size_t len,
Ts &&... ts )
inline

High level allocator method, which return a pointer to an array of class or struct allocated with the specialized subclass strategy

Parameters
lenthe array length
tsargument(s) for the constructor of the type T
Returns
a non null pointer to an array of new object(s) of type T
Exceptions
std::bad_allocis no memory could be allocated

Member Data Documentation

◆ impl

struct AllocatorImpl* zyncarla::Allocator::impl

◆ max_transaction_length

const size_t zyncarla::Allocator::max_transaction_length = 256
staticprivate

◆ transaction_active

bool zyncarla::Allocator::transaction_active
private

◆ transaction_alloc_content

void* zyncarla::Allocator::transaction_alloc_content[max_transaction_length]
private

◆ transaction_alloc_index

size_t zyncarla::Allocator::transaction_alloc_index
private

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