tanya.memory.allocator

This module contains the interface for implementing custom allocators.

Allocators are classes encapsulating memory allocation strategy. This allows to decouple memory management from the algorithms and the data.

Members

Classes

OutOfMemoryError
class OutOfMemoryError

Error thrown if memory allocation fails.

Functions

alignedSize
size_t alignedSize(size_t size, size_t alignment)
dispose
void dispose(Allocator allocator, T p)

Destroys and deallocates p of type T. It is assumed the respective entities had been allocated with the same allocator.

finalize
void[] finalize(T* p)
Undocumented in source. Be warned that the author may not have intended to support it.
finalize
void[] finalize(T p)
Undocumented in source. Be warned that the author may not have intended to support it.
finalize
void[] finalize(T[] p)
Undocumented in source. Be warned that the author may not have intended to support it.
make
T make(Allocator allocator, A args)

Constructs a new class instance of type T using args as the parameter list for the constructor of T.

make
T* make(Allocator allocator, A args)

Constructs a value object of type T using args as the parameter list for the constructor of T and returns a pointer to the new object.

make
T make(Allocator allocator, size_t n)

Constructs a new array with n elements.

onOutOfMemoryError
void onOutOfMemoryError(string msg)

Allocates $(D_PSYMBOL OutOfMemoryError) in a static storage and throws it.

resize
T[] resize(Allocator allocator, T[] array, size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.

Interfaces

Allocator
interface Allocator

Abstract class implementing a basic allocator.

Mixin templates

DefaultAllocator
mixintemplate DefaultAllocator()

The mixin generates common methods for classes and structs using allocators. It provides a protected member, constructor and a read-only property, that checks if an allocator was already set and sets it to the default one, if not (useful for structs which don't have a default constructor).

Properties

defaultAllocator
shared(Allocator) defaultAllocator [@property getter]
defaultAllocator
void defaultAllocator [@property getter]

Sets the default allocator.

Templates

GetPureInstance
template GetPureInstance(T : Allocator)
Undocumented in source.

Variables

allocator
Allocator allocator;
Undocumented in source.

Meta