View source code
Display the source code in std/experimental/allocator/package.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Interface std.experimental.allocator.ISharedAllocator

Dynamic shared allocator interface. Code that defines allocators shareable across threads ultimately implements this interface. This should be used wherever a uniform type is required for encapsulating various allocator implementations.

interface ISharedAllocator ;

Composition of allocators is not recommended at this level due to inflexibility of dynamic interfaces and inefficiencies caused by cascaded multiple calls. Instead, compose allocators using the static interface defined in std.experimental.allocator.building_blocks, then adapt the composed allocator to ISharedAllocator (possibly by using CSharedAllocatorImpl below).

Methods returning Ternary return Ternary.yes upon success, Ternary.no upon failure, and Ternary.unknown if the primitive is not implemented by the allocator instance.

Properties

NameTypeDescription
alignment[get] uintReturns the alignment offered.

Methods

NameDescription
alignedAllocate (n, a) Allocates n bytes of memory with specified alignment a. Implementations that do not support this primitive should always return null.
alignedReallocate (b, size, alignment) Reallocates a memory block with specified alignment.
allocate (, ti) Allocates n bytes of memory.
allocateAll () Allocates and returns all memory available to this allocator. Implementations that do not support this primitive should always return null.
deallocate (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 () Deallocates all memory. Implementations that don't support this primitive should always return false.
decRef () Decreases the reference count of the concrete class that implements this interface. When the reference count is 0, the object self-destructs.
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.
expand (, ) Expands a memory block in place and returns true if successful. Implementations that don't support this primitive should always return false.
goodAllocSize (s) Returns the good allocation size that guarantees zero internal fragmentation.
incRef () Increases the reference count of the concrete class that implements this interface.
owns (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.
reallocate (, ) Reallocates a memory block.
resolveInternalPointer (p, result) Resolves an internal pointer to the full block allocated. Implementations that don't support this primitive should always return Ternary.unknown.

Authors

Andrei Alexandrescu

License

Boost License 1.0.