OpenVPN 3 Core Library
|
implements a simple reference count for objects. More...
#include <rc.hpp>
Public Member Functions | |
thread_unsafe_refcount () noexcept | |
Construct a new thread unsafe refcount::thread unsafe refcount object. | |
void | operator++ () noexcept |
Increment ref count by 1. | |
olong | operator-- () noexcept |
Decrement ref count by 1. | |
bool | inc_if_nonzero () noexcept |
Increments refcount by 1 if refcount is not 0, returns true if it incremented refcount. | |
olong | use_count () const noexcept |
Returns the internal use count. | |
Static Public Member Functions | |
static constexpr bool | is_thread_safe () |
Returns false for this type. | |
Private Member Functions | |
thread_unsafe_refcount (const thread_unsafe_refcount &)=delete | |
thread_unsafe_refcount & | operator= (const thread_unsafe_refcount &)=delete |
Private Attributes | |
olong | rc |
The reference count, platform efficient integer type. | |
implements a simple reference count for objects.
The purpose of thread_unsafe_refcount is to keep track of how many references exist to an object and automatically delete the object when the reference count reaches zero. It provides methods to increment, decrement, and read the current reference count.
thread_unsafe_refcount contains a member variable rc which holds the current reference count number as a type olong. Overall, thread_unsafe_refcount provides simple reference counting functionality to track object references in a single-threaded context. It could be used to implement basic automatic memory management based on scope and references for objects.
|
inlinenoexcept |
|
privatedelete |
|
inlinenoexcept |
|
inlinestaticconstexpr |
|
inlinenoexcept |
|
inlinenoexcept |
|
privatedelete |
|
inlinenoexcept |
|
private |