FreeList

Undocumented in source.

Destructor

~this
~this()

If ParentAllocator defines deallocate, the list frees all nodes on destruction. FreeList!(0, unbounded) does not deallocate the memory on destruction.

Members

Aliases

alignment
alias alignment = ParentAllocator.alignment

Alignment offered.

max
alias max = maxSize
Undocumented in source.
min
alias min = minSize
Undocumented in source.
parent
alias parent = ParentAllocator.instance
Undocumented in source.

Functions

allocate
void[] allocate(size_t n)

Allocates memory either off of the free list or from the parent allocator. If n is within [min, max] or if the free list is unchecked (minSize == 0 && maxSize == size_t.max), then the free list is consulted first. If not empty (hit), the block at the front of the free list is removed from the list and returned. Otherwise (miss), a new block of max bytes is allocated, truncated to n bytes, and returned.

deallocate
bool deallocate(void[] block)

If block.length is within [min, max] or if the free list is unchecked (minSize == 0 && maxSize == size_t.max), then inserts the block at the front of the free list. For all others, forwards to parent.deallocate if Parent.deallocate is defined.

deallocateAll
bool deallocateAll()

Defined only if ParentAllocator defines deallocateAll. If so, forwards to it and resets the freelist.

goodAllocSize
size_t goodAllocSize(size_t bytes)

If maxSize == unbounded, returns parent.goodAllocSize(bytes). Otherwise, returns max for sizes in the interval [min, max], and parent.goodAllocSize(bytes) otherwise.

minimize
void minimize()

Nonstandard function that minimizes the memory usage of the freelist by freeing each element in turn. Defined only if ParentAllocator defines deallocate. FreeList!(0, unbounded) does not have this function.

updateStats
void updateStats()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

max
size_t max [@property getter]

Returns the largest allocation size eligible for allocation from the freelist. (If maxSize != chooseAtRuntime, this is simply an alias for maxSize.) All allocation requests for sizes greater than or equal to min and less than or equal to max are rounded to max and forwarded to the parent allocator. When the block fitting the same constraint gets deallocated, it is put in the freelist with the allocated size assumed to be max.

max
size_t max [@property setter]

If FreeList has been instantiated with maxSize == chooseAtRuntime, then the max property is writable. Setting it must precede any allocation.

min
size_t min [@property getter]

Returns the smallest allocation size eligible for allocation from the freelist. (If minSize != chooseAtRuntime, this is simply an alias for minSize.)

min
size_t min [@property setter]

If FreeList has been instantiated with minSize == chooseAtRuntime, then the min property is writable. Setting it must precede any allocation.

Variables

parent
ParentAllocator parent;

The parent allocator. Depending on whether ParentAllocator holds state or not, this is a member variable or an alias for ParentAllocator.instance.

Meta