std.experimental.allocator.building_blocks.aligned_block_list

AlignedBlockList represents a wrapper around a chain of allocators, allowing for fast deallocations and preserving a low degree of fragmentation by means of aligned allocations.

Source: std/experimental/allocator/building_blocks/aligned_block_list.d

Types 2

structAlignedBlockList(Allocator, ParentAllocator, ulong theAlignment = (1 << 21))

AlignedBlockList represents a wrapper around a chain of allocators, allowing for fast deallocations and preserving a low degree of fragmentation. The allocator holds internally a doubly linked list of Allocator objects, which will serve allocations in a most-recently-used fashion. Most recent allocators used for allocate calls, will be moved to the front of the list.

Although allocations are in theory served in linear searching time, deallocate calls take 1 time, by using aligned allocations. ParentAllocator must implement alignedAllocate and it must be able to allocate theAlignment bytes at the same alignment. Each aligned allocation done by ParentAllocator will contain metadata for an Allocator, followed by its payload.

Parameters

Allocatorthe allocator which is used to manage each node; it must have a constructor which receives ubyte[] and it must not have any parent allocators, except for the NullAllocator
ParentAllocatoreach node draws memory from the parent allocator; it must support alignedAllocate
theAlignmentalignment of each block and at the same time length of each node
structSharedAlignedBlockList(Allocator, ParentAllocator, ulong theAlignment = (1 << 21))

SharedAlignedBlockList is the threadsafe version of AlignedBlockList. The Allocator template parameter must refer a shared allocator. Also, ParentAllocator must be a shared allocator, supporting alignedAllocate.

Parameters

Allocatorthe shared allocator which is used to manage each node; it must have a constructor which receives ubyte[] and it must not have any parent allocators, except for the NullAllocator
ParentAllocatoreach node draws memory from the parent allocator; it must be shared and support alignedAllocate
theAlignmentalignment of each block and at the same time length of each node