uvco 0.1
|
#include <internal_utils.h>
Public Member Functions | |
RefCounted (const RefCounted &other)=default | |
RefCounted & | operator= (const RefCounted &other)=default |
RefCounted (RefCounted &&other) noexcept | |
RefCounted & | operator= (RefCounted &&other) noexcept |
virtual | ~RefCounted ()=default |
virtual T * | addRef () |
virtual void | delRef () |
Protected Member Functions | |
RefCounted ()=default | |
Private Attributes | |
size_t | count_ = 1 |
RefCounted<T>
is an intrusive refcounting approach, which reduces the run-time of low-overhead high frequency promise code (such as buffered channel ping-pong scenarios) by as much as 50% compared to shared_ptr
use. However, manual refcounting is required by objects owning a refcounted object.
Use makeRefCounted()
to allocate a new reference-counted object, and store it as part of your class. Use addRef()
and delRef()
to keep track of the current number of references.
This type currently doesn't work well with inheritance: only a class directly inheriting from RefCounted
can be managed. This is caused by the current API approach.
|
default |
|
inlinenoexcept |
|
virtualdefault |
|
protecteddefault |
|
inlinevirtual |
Use in e.g. copy constructors, when creating a new reference to the same object.
|
inlinevirtual |
|
default |
|
inlinenoexcept |
|
private |