Nebula
|
#include <rangeallocator.h>
Allocates memory ranges using the TLSF method, with extended handling of padding to better suit GPUs.
Doesn't manage memory itself but is meant to be used with a memory allocation/buffer of maxSize. Fast O(1) insertion and deletion and with minimal fragmentation.
More details: http://www.gii.upv.es/tlsf/files/ecrts04_tlsf.pdf
Classes | |
union | BinIndex |
struct | RangeAllocatorNode |
Public Member Functions | |
RangeAllocator () | |
Default constructor. | |
RangeAllocator (uint size, SizeT maxNumAllocs) | |
Construct with predetermined size and max allowed number of allocations. | |
~RangeAllocator () | |
Destructor. | |
void | Clear () |
Clears the allocator. | |
bool | Empty () |
Checks if the allocator is empty. | |
RangeAllocation | Alloc (uint size, uint alignment=1) |
Allocate range. | |
void | Dealloc (const RangeAllocation &allocation) |
Deallocate range. | |
Private Member Functions | |
uint | InsertNode (uint size, uint offset) |
Insert node at bin location, return node index. | |
void | RemoveNode (uint nodeIndex) |
Remove node from bin. | |
Static Private Member Functions | |
static BinIndex | IndexFromSize (uint size, bool round=false) |
Get bin index from size. | |
static uint | BucketFromSize (uint size) |
Get bucket from index. | |
static uint | BinFromSize (uint size, uint bucket) |
Get bin from index. | |
Private Attributes | |
uint | size |
uint | freeStorage |
uint | freeNodeIterator |
uint | bucketUsageMask |
uint | binMasks [NUM_BUCKETS] |
uint | binHeads [NUM_BUCKETS *NUM_BINS_PER_BUCKET] |
Util::Array< RangeAllocatorNode > | nodes |
Util::Array< uint > | freeNodes |
Static Private Attributes | |
static constexpr uint | NUM_BUCKETS = 0x20 |
static constexpr uint | NUM_BINS_PER_BUCKET = 0x10 |
|
inline |
Default constructor.
Construct with predetermined size and max allowed number of allocations.
|
inline |
Destructor.
|
inline |
Allocate range.
Returns a range using the TLSF method.
Get bin from index.
|
inline |
Clears the allocator.
|
inline |
Deallocate range.
|
inline |
Checks if the allocator is empty.
|
inlinestaticprivate |
Get bin index from size.
Insert node at bin location, return node index.
|
inlineprivate |
Remove node from bin.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |