A pager implementing the free list pattern. More...
Public Member Functions | |
FreeListPager (unsigned long long pageSize, UniquePtr< MemorySpaceAllocator< U >> allocator=makeUnique< DefaultMemorySpaceAllocator< U >>()) noexcept | |
FreeListPager (const FreeListPager &) noexcept=delete | |
FreeListPager (FreeListPager &&) noexcept=default | |
unsigned long long | getPageSize () const |
unsigned long long | getAllocatedPageCount () const |
const FreeListMemorySpaceWrapper< T, U > & | getPage (unsigned long long index) |
FreeListAllocation< T > | allocate (unsigned long long size, unsigned long long alignment=1) |
void | free (unsigned long long allocationIndex) |
FreeListPager & | operator= (const FreeListPager &) noexcept=delete |
FreeListPager & | operator= (FreeListPager &&) noexcept=default |
A pager implementing the free list pattern.
This pattern keeps track of allocations within the pages, and returns allocations fitting the requirements within the memory space allocated. Allocations can be freed individually. This pager can be used when data will be kept around, with no knowledge about the lifetime of it.
For instance, in a 3d renderer, gpu resources can be placed within a memory space as they come and go, reducing the need for memory allocations.
|
noexcept |
Constructor.
pageSize | The size to use for pages, in number of elements. |
allocator | The memory space allocator, allowing to customize how the pages are allocated. |
|
deletenoexcept |
Copy constructor.
|
defaultnoexcept |
Move constructor.
unsigned long long nkMemory::FreeListPager< T, U >::getPageSize | ( | ) | const |
unsigned long long nkMemory::FreeListPager< T, U >::getAllocatedPageCount | ( | ) | const |
const FreeListMemorySpaceWrapper<T, U>& nkMemory::FreeListPager< T, U >::getPage | ( | unsigned long long | index | ) |
FreeListAllocation<T> nkMemory::FreeListPager< T, U >::allocate | ( | unsigned long long | size, |
unsigned long long | alignment = 1 |
||
) |
Requests an allocation.
size | The size of the allocation needed, in number of elements. |
alignment | The needed alignment in the memory space. |
void nkMemory::FreeListPager< T, U >::free | ( | unsigned long long | allocationIndex | ) |
Releases an allocation so that it returns within the pager.
allocationIndex | The index for the allocation to free. Provided by allocate(). |
|
deletenoexcept |
Copy assignment.
|
defaultnoexcept |
Move assignment.