![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
#include <memory_stack.hpp>
Classes | |
class | HighAllocator |
class | LowAllocator |
Public Member Functions | |
DoubleEndedMemoryStack (std::size_t size, std::size_t alignment) | |
DoubleEndedMemoryStack (const DoubleEndedMemoryStack &stack)=delete | |
DoubleEndedMemoryStack (DoubleEndedMemoryStack &&stack) noexcept | |
~DoubleEndedMemoryStack () | |
DoubleEndedMemoryStack & | operator= (const DoubleEndedMemoryStack &stack)=delete |
DoubleEndedMemoryStack & | operator= (DoubleEndedMemoryStack &&stack)=delete |
std::size_t | GetAlignment () const noexcept |
std::size_t | GetSize () const noexcept |
std::size_t | GetUsedSize () const noexcept |
std::size_t | GetUsedLowSize () const noexcept |
std::size_t | GetUsedHighSize () const noexcept |
std::size_t | GetAvailableSize () const noexcept |
std::uintptr_t | GetCurrentLowPtr () const noexcept |
std::uintptr_t | GetCurrentHighPtr () const noexcept |
void | Reset () noexcept |
void | RollBackLow (std::uintptr_t ptr) noexcept |
void | RollBackHigh (std::uintptr_t ptr) noexcept |
void * | AllocLow (std::size_t size) noexcept |
void * | AllocHigh (std::size_t size) noexcept |
template<typename T > | |
T * | AllocDataLow (std::size_t count=1u, bool initialization=false) |
template<typename T > | |
T * | AllocDataHigh (std::size_t count=1u, bool initialization=false) |
template<typename T > | |
LowAllocator< T > | GetLowAllocator () noexcept |
template<typename T > | |
HighAllocator< T > | GetHighAllocator () noexcept |
Private Attributes | |
const std::size_t | m_size |
const std::size_t | m_alignment |
std::uintptr_t | m_begin |
std::uintptr_t | m_current_low |
std::uintptr_t | m_current_high |
A class of double-ended memory stacks.
|
explicit |
Constructs a double-ended memory stack with given size.
[in] | size | The size in bytes. |
[in] | alignment | The alignment in bytes. |
std::bad_alloc | Failed to allocate the memory. |
|
delete |
Constructs a double-ended memory stack from the given double-ended memory stack.
[in] | stack | A reference to the double-ended memory stack to copy. |
|
defaultnoexcept |
Constructs a double-ended memory stack by moving the given double-ended memory stack.
[in] | stack | A reference to the double-ended memory stack to move. |
mage::DoubleEndedMemoryStack::~DoubleEndedMemoryStack | ( | ) |
Destructs this double-ended memory stack.
T* mage::DoubleEndedMemoryStack::AllocDataHigh | ( | std::size_t | count = 1u , |
bool | initialization = false |
||
) |
Allocates a block of memory on the high side of this memory stack.
T | The data type. |
[in] | count | The number of objects of type T to allocate in memory. |
[in] | initialization | Flag indicating whether the objects need to be initialized (i.e. the constructor needs to be called). |
nullptr
if the allocation failed. T* mage::DoubleEndedMemoryStack::AllocDataLow | ( | std::size_t | count = 1u , |
bool | initialization = false |
||
) |
Allocates a block of memory on the low side of this memory stack.
T | The data type. |
[in] | count | The number of objects of type T to allocate in memory. |
[in] | initialization | Flag indicating whether the objects need to be initialized (i.e. the constructor needs to be called). |
nullptr
if the allocation failed.
|
noexcept |
Allocates a block of memory of the given size on the high side of this memory stack.
[in] | size | The requested size in bytes to allocate in memory. |
nullptr
if the allocation failed.
|
noexcept |
Allocates a block of memory of the given size on the low side of this memory stack.
[in] | size | The requested size in bytes to allocate in memory. |
nullptr
if the allocation failed.
|
noexcept |
Returns the alignment of this double-ended memory stack.
|
noexcept |
Returns the available size of this double-ended memory stack.
|
noexcept |
Returns a pointer to the current high position of this double-ended memory stack.
|
noexcept |
Returns a pointer to the current low position of this double-ended memory stack.
|
noexcept |
Returns a high allocator for this single-ended memory stack.
T | The data type of the allocator. |
|
noexcept |
Returns a low allocator for this single-ended memory stack.
T | The data type of the allocator. |
|
noexcept |
Returns the size (used + available) of this double-ended memory stack.
|
noexcept |
Returns the used high size of this double-ended memory stack.
|
noexcept |
Returns the used low size of this double-ended memory stack.
|
noexcept |
Returns the used size of this double-ended memory stack.
|
delete |
Copies the given double-ended memory stack to this double-ended memory stack.
[in] | stack | A reference to the double-ended memory stack to copy. |
|
delete |
Moves the given double-ended memory stack to this double-ended memory stack.
[in] | stack | A reference to the double-ended memory stack to move. |
|
noexcept |
Resets this double-ended memory stack.
The pointer to the current low position of this double-ended memory stack will be reset to the begin position of this double-ended memory stack. The pointer to the current high position of this double-ended memory stack will be reset to the end position of this double-ended memory stack.
|
noexcept |
Rolls this double-ended memory stack back to the given high position.
[in] | ptr | The pointer to the requested high position of this memory stack. |
|
noexcept |
Rolls this double-ended memory stack back to the given low position.
[in] | ptr | The pointer to the requested low position of this memory stack. |
|
private |
The alignment in bytes of this double-ended memory stack.
|
private |
A pointer to the begin of this double-ended memory stack.
|
private |
A pointer to the current high position of this double-ended memory stack.
|
private |
A pointer to the current low position of this double-ended memory stack.
|
private |
The size in bytes of this double-ended memory stack.