BucketElementMallocAllocator

Implements a malloc based BucketElement Allactor.

By default the class constructor checks the type of the Bucket elements (i.e, the values stored in the Map). If the element contains reference items (e.g class or an array) then on malloc allocations the class adds the elements to the GC scan range and removes them from the GC scan range on recycling.

This tracking of the objects can be explicitly disabled through passing the appropriate flag to the class constructor.

Constructors

this
this(bool attempt_gc_track)

Constructor.

Members

Classes

ParkingStack
class ParkingStack

Class for parking elements

Functions

allocate
void* allocate()

Get new element

deallocate
void deallocate(void* element)

delete element

parkElements
void parkElements(size_t n, void delegate(IParkingStack park) dg)

Park elements

Inherited Members

From IAllocator

bucket_element_size
size_t bucket_element_size;

Stores the size of a single allocated element.

get
void* get()

Gets or allocates an object

allocate
void* allocate()

Performs the actual allocation of an object

recycle
void recycle(void* old)

Recycles or deletes an object that is no longer used.

deallocate
void deallocate(void* old)

Performs the actual recycling of an object. See recycle() documentation.

memoryUsed
size_t memoryUsed()

Return the amount of memory currently used.

IParkingStack
class IParkingStack

Helper class to temprarily park a certain number of objects.

parkElements
void parkElements(size_t n, void delegate(IParkingStack park) dg)

Calls dg with an IParkingStack instance that is set up to keep n elements.

Parameters

Bucket

the bucket-element type

Meta