IRC_SERVER
By @hyunjunk (hyunjun2372@gmail.com)
Loading...
Searching...
No Matches
IRCCore::FixedMemoryPool< T, MemoryPageCapacity > Class Template Reference

Memory pool that can allocate fixed amount of data. More...

#include <FixedMemoryPool.hpp>

Public Member Functions

 FixedMemoryPool ()
 
 ~FixedMemoryPool ()
 
T * Allocate ()
 Allocate a data.
 
void Deallocate (T *ptr)
 Deallocate a data.
 
bool IsCapacityFull () const
 
bool IsInPool (const void *ptr) const
 
size_t GetUsed () const
 
size_t GetCapacity () const
 

Private Types

enum  { CAPACITY = MemoryPageCapacity * PAGE_SIZE / sizeof(T) }
 

Private Attributes

size_t mCapacity
 
size_t mIndices [CAPACITY]
 
size_t mCursor
 
char * mMemoryRaw
 

Detailed Description

template<typename T, size_t MemoryPageCapacity>
class IRCCore::FixedMemoryPool< T, MemoryPageCapacity >

Memory pool that can allocate fixed amount of data.

Allocates raw memory on a per-page basis ( see PAGE_SIZE ), and manages data there. Also uses an index array filled sequentially from 1 to N, and a corresponding cursor to identify allocatable data.

Template Parameters
TType of data to allocate
MemoryPageCapacityNumber of pages to allocate. (see details)

Member Enumeration Documentation

◆ anonymous enum

template<typename T , size_t MemoryPageCapacity>
anonymous enum
private
Enumerator
CAPACITY 

Constructor & Destructor Documentation

◆ FixedMemoryPool()

template<typename T , size_t MemoryPageCapacity>
IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::FixedMemoryPool ( )
inline

◆ ~FixedMemoryPool()

template<typename T , size_t MemoryPageCapacity>
IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::~FixedMemoryPool ( )
inline

Member Function Documentation

◆ Allocate()

template<typename T , size_t MemoryPageCapacity>
T * IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::Allocate ( )
inline

Allocate a data.

◆ Deallocate()

template<typename T , size_t MemoryPageCapacity>
void IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::Deallocate ( T * ptr)
inline

Deallocate a data.

Parameters
ptrPointer to the data to deallocate

◆ IsCapacityFull()

template<typename T , size_t MemoryPageCapacity>
bool IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::IsCapacityFull ( ) const
inline

◆ IsInPool()

template<typename T , size_t MemoryPageCapacity>
bool IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::IsInPool ( const void * ptr) const
inline

◆ GetUsed()

template<typename T , size_t MemoryPageCapacity>
size_t IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::GetUsed ( ) const
inline

◆ GetCapacity()

template<typename T , size_t MemoryPageCapacity>
size_t IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::GetCapacity ( ) const
inline

Member Data Documentation

◆ mCapacity

template<typename T , size_t MemoryPageCapacity>
size_t IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::mCapacity
private

◆ mIndices

template<typename T , size_t MemoryPageCapacity>
size_t IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::mIndices[CAPACITY]
private

◆ mCursor

template<typename T , size_t MemoryPageCapacity>
size_t IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::mCursor
private

◆ mMemoryRaw

template<typename T , size_t MemoryPageCapacity>
char* IRCCore::FixedMemoryPool< T, MemoryPageCapacity >::mMemoryRaw
private

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