Container.GCChunk

GCChunk allocator

Like the Chunk allocator, this allocates elements in chunks, but allows you to allocate elements that can have GC pointers.

Tests have shown about a 60% speedup when using the GC chunk allocator for a Hashmap!(int, int).

Members

Functions

allocate
T* allocate()

Allocate a T*

allocate
T*[] allocate(uint count)
Undocumented in source. Be warned that the author may not have intended to support it.
collect
void collect(T* t)

free a T*

collect
void collect(T*[] t)
Undocumented in source. Be warned that the author may not have intended to support it.
collect
bool collect(bool all)

Deallocate all chunks used by this allocator. Depends on the GC to do the actual collection

config
void config(size_t chunks, int allocate)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

chunk
struct chunk

A chunk of elements

element
struct element

This is the form used to link recyclable elements together.

Variables

fresh
chunk* fresh;

The fresh chunk. This is only used if no elements are available in the used chain.

nextFresh
uint nextFresh;

The next element in the fresh chunk. Because we don't worry about the free list in the fresh chunk, we need to keep track of the next fresh element to use.

used
chunk* used;

The chain of used chunks. Used chunks have had all their elements allocated at least once.

Meta