The OpenD Programming Language

SharedRegion

The threadsafe version of the Region allocator. Allocations and deallocations are lock-free based using core.atomic.cas.

Constructors

this
this(ubyte[] store)
this(size_t n)

Constructs a region backed by a user-provided store. Assumes the memory was allocated with ParentAllocator.

Destructor

~this
~this()

If ParentAllocator defines deallocate, the region defines a destructor that uses ParentAllocator.deallocate to free the memory chunk.

Members

Aliases

alignment
alias alignment = minAlign

Alignment offered.

Functions

alignedAllocate
void[] alignedAllocate(size_t n, uint a)

Allocates n bytes of memory aligned at alignment a.

allocate
void[] allocate(size_t n)

Allocates n bytes of memory. The allocation is served by atomically incrementing a pointer which keeps track of the current used space.

deallocate
bool deallocate(void[] b)

Deallocates b. This works only if b was obtained as the last call to allocate; otherwise (i.e. another allocation has occurred since) it does nothing.

deallocateAll
bool deallocateAll()

Deallocates all memory allocated by this region, which can be subsequently reused for new allocations.

empty
Ternary empty()

Returns Ternary.yes if no memory has been allocated in this region, Ternary.no otherwise. (Never returns Ternary.unknown.)

goodAllocSize
size_t goodAllocSize(size_t n)

Rounds the given size to a multiple of the alignment

owns
Ternary owns(void[] b)

Queries whether b has been allocated with this region.

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