The OpenD Programming Language

CSharedAllocatorImpl

Implementation of ISharedAllocator using Allocator. This adapts a statically-built, shareable across threads, allocator type to ISharedAllocator that is directly usable by non-templated code.

Usually CSharedAllocatorImpl is used indirectly by calling processAllocator.

Constructors

this
this(Allocator* pa)

The implementation is available as a public member.

Members

Functions

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

If impl.alignedAllocate exists, calls it and returns the result. Otherwise, always returns null.

alignedReallocate
bool alignedReallocate(void[] b, size_t s, uint a)

Forwards to impl.alignedReallocate if defined, false otherwise.

allocate
void[] allocate(size_t s, TypeInfo ti)

Returns impl.allocate(s).

allocateAll
void[] allocateAll()

Returns impl.allocateAll() if present, null otherwise.

deallocate
bool deallocate(void[] b)

If impl.deallocate is not defined, returns false. Otherwise it forwards the call.

deallocateAll
bool deallocateAll()

Calls impl.deallocateAll() and returns the result if defined, otherwise returns false.

empty
Ternary empty()

Forwards to impl.empty() if defined, otherwise returns Ternary.unknown.

expand
bool expand(void[] b, size_t s)

Returns impl.expand(b, s) if defined, false otherwise.

goodAllocSize
size_t goodAllocSize(size_t s)

Returns impl.goodAllocSize(s).

impl
Allocator impl()

The implementation is available as a public member.

owns
Ternary owns(void[] b)

If Allocator implements owns, forwards to it. Otherwise, returns Ternary.unknown.

reallocate
bool reallocate(void[] b, size_t s)

Returns impl.reallocate(b, s).

Properties

alignment
uint alignment [@property getter]

Returns impl.alignment.

Inherited Members

From ISharedAllocator

alignment
uint alignment [@property getter]

Returns the alignment offered.

goodAllocSize
size_t goodAllocSize(size_t s)

Returns the good allocation size that guarantees zero internal fragmentation.

allocate
void[] allocate(size_t , TypeInfo ti)

Allocates n bytes of memory.

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

Allocates n bytes of memory with specified alignment a. Implementations that do not support this primitive should always return null.

allocateAll
void[] allocateAll()

Allocates and returns all memory available to this allocator. Implementations that do not support this primitive should always return null.

expand
bool expand(void[] , size_t )

Expands a memory block in place and returns true if successful. Implementations that don't support this primitive should always return false.

reallocate
bool reallocate(void[] , size_t )

Reallocates a memory block.

alignedReallocate
bool alignedReallocate(void[] b, size_t size, uint alignment)

Reallocates a memory block with specified alignment.

owns
Ternary owns(void[] b)

Returns Ternary.yes if the allocator owns b, Ternary.no if the allocator doesn't own b, and Ternary.unknown if ownership cannot be determined. Implementations that don't support this primitive should always return Ternary.unknown.

resolveInternalPointer
Ternary resolveInternalPointer(void* p, void[] result)

Resolves an internal pointer to the full block allocated. Implementations that don't support this primitive should always return Ternary.unknown.

deallocate
bool deallocate(void[] b)

Deallocates a memory block. Implementations that don't support this primitive should always return false. A simple way to check that an allocator supports deallocation is to call deallocate(null).

deallocateAll
bool deallocateAll()

Deallocates all memory. Implementations that don't support this primitive should always return false.

empty
Ternary empty()

Returns Ternary.yes if no memory is currently allocated from this allocator, Ternary.no if some allocations are currently active, or Ternary.unknown if not supported.

incRef
void incRef()

Increases the reference count of the concrete class that implements this interface.

decRef
bool decRef()

Decreases the reference count of the concrete class that implements this interface. When the reference count is 0, the object self-destructs.

Meta