RcPtr

Implementation of a ref counted pointer without support for aliasing (smaller size of pointer).

RcPtr retains shared ownership of an object through a pointer.

Several ref counted pointer objects may own the same object.

The object is destroyed and its memory deallocated when either of the following happens:

1. the last remaining ref counted pointer owning the object is destroyed.

2. the last remaining ref counted pointer owning the object is assigned another pointer via various methods like opAssign and store.

The object is destroyed using destructor of type _Type.

A RcPtr can not share ownership of an object while storing a pointer to another object (use SharedPtr for that). The stored pointer is the one accessed by get(), the dereference and the comparison operators.

A RcPtr may also own no objects, in which case it is called empty.

If template parameter _ControlType is shared then all member functions (including copy constructor and copy assignment) can be called by multiple threads on different instances of RcPtr without additional synchronization even if these instances are copies and share ownership of the same object.

If multiple threads of execution access the same RcPtr (shared RcPtr) then only some methods can be called (load, store, exchange, compareExchange, useCount).

Template parameters:

_Type type of managed object

_DestructorType function pointer with attributes of destructor, to get attributes of destructor from type use btl.autoptr.common.DestructorType!T. Destructor of type _Type must be compatible with _DestructorType

_ControlType represent type of counter, must by of type btl.autoptr.common.ControlBlock. if is shared then ref counting is atomic.

_weakPtr if true then RcPtr represent weak ptr

  1. template RcPtr(_Type, _DestructorType = DestructorType!_Type, _ControlType = ControlBlockDeduction!(_Type, SharedControlBlock), bool _weakPtr = false)
    template RcPtr (
    _Type
    _DestructorType = DestructorType!_Type
    _ControlType = ControlBlockDeduction!(_Type, SharedControlBlock)
    bool _weakPtr = false
    ) if (
    isControlBlock!_ControlType &&
    isDestructorType!_DestructorType
    ) {}
  2. template RcPtr(_Type, _ControlType, _DestructorType = DestructorType!_Type)

Members

Functions

check_dtor
void check_dtor()
Undocumented in source. Be warned that the author may not have intended to support it.

Imports

AliasSeq (from std.meta)
public import std.meta : AliasSeq;
Undocumented in source.
CopyConstness (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
CopyTypeQualifiers (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
ElementEncodingType (from std.range)
public import std.range : ElementEncodingType;
Undocumented in source.
MemoryOrder (from core.atomic)
public import core.atomic : MemoryOrder;
Undocumented in source.
Select (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
Unconst (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
Unqual (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
forward (from core.lifetime)
public import core.lifetime : forward;
Undocumented in source.
hasElaborateDestructor (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
hasIndirections (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
isAbstractClass (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
isArray (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
isCallable (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
isDynamicArray (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
isMutable (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.
isStaticArray (from std.traits)
public import std.traits : Unqual, Unconst, CopyTypeQualifiers, CopyConstness, hasIndirections, hasElaborateDestructor, isMutable, isAbstractClass, isDynamicArray, isStaticArray, isCallable, Select, isArray;
Undocumented in source.

Structs

RcPtr
struct RcPtr
Undocumented in source.

Variables

_isLockFree
enum bool _isLockFree;
Undocumented in source.
hasSharedCounter
enum bool hasSharedCounter;
Undocumented in source.
hasWeakCounter
enum bool hasWeakCounter;
Undocumented in source.
referenceElementType
enum bool referenceElementType;
Undocumented in source.

Meta