RefCounted

RefCounted is a smart pointer that retains shared ownership of an object through a pointer. Several RefCounted objects may own the same object. The object is destroyed and its memory deallocated when either of the following happens:

* the last remaining RefCounted owning the object is destroyed; * the last remaining RefCounted owning the object is assigned another pointer via opAssign or release().

The object is destroyed using the objects destructor.

A RefCounted may also own no objects, in which case it is called empty and isNull() returns true.

All member functions can be called by multiple threads on different instances of shared_ptr without additional synchronization even if these instances are copies and share ownership of the same object. If multiple threads of execution access the same shared_ptr without synchronization and any of those accesses uses a non-const member function of shared_ptr then a data race will occur; the shared_ptr overloads of atomic functions can be used to prevent the data race.

Constructors

this
this(Impl* impl)
Undocumented in source.
this
this(Args args)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

Impl
alias Impl = ControlBlock!T
Undocumented in source.

Functions

empty
bool empty()
Undocumented in source. Be warned that the author may not have intended to support it.
get
inout(T) get()
Undocumented in source. Be warned that the author may not have intended to support it.
opAssign
void opAssign(RefCounted other)
Undocumented in source. Be warned that the author may not have intended to support it.
opAssign
void opAssign(T other)
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
T opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
ptr
inout(T*) ptr()
refCount
int refCount()

The number of references.

release
void release()

Release the reference.

toHash
size_t toHash()
Undocumented in source. Be warned that the author may not have intended to support it.
weakRef
WeakRef!T weakRef()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta