OpenVPN 3 Core Library
|
Reference count base class for objects tracked by RCPtr. Like RC, but also allows weak pointers and release notification callables. More...
#include <rc.hpp>
Classes | |
struct | Controller |
Controller structure for our ptr/weakptr implementation. More... | |
struct | ControllerRef |
Adapter object for RCWeak::Controller <—> RCPtr. More... | |
Public Types | |
typedef RCPtr< RCWeak > | Ptr |
typedef RCWeakPtr< RCWeak > | WPtr |
Public Member Functions | |
RCWeak () noexcept | |
virtual | ~RCWeak ()=default |
RCWeak (const RCWeak &)=delete | |
RCWeak & | operator= (const RCWeak &)=delete |
Private Attributes | |
ControllerRef | refcount_ |
Adapter instance that allows RCPtr to properly interact with RCWeak. | |
Friends | |
template<typename T > | |
class | RCWeakPtr |
template<typename R > | |
void | intrusive_ptr_add_ref (R *rcptr) noexcept |
Helper to increment a ref count. | |
template<typename R > | |
void | intrusive_ptr_release (R *rcptr) noexcept |
Helper to decrement a ref count. | |
Reference count base class for objects tracked by RCPtr. Like RC, but also allows weak pointers and release notification callables.
RCImpl | The ref count implementation that will be used - thread_safe_refcount or thread_unsafe_refcount |
Implements basic reference counting functionality for objects plus weak pointer capability.
The purpose of RCWeak is to provide a base class that other classes can inherit from to enable reference counting and automatic memory management. It takes a template parameter RCImpl which specifies the actual reference count implementation class that will be used, either thread_safe_refcount or thread_unsafe_refcount.
RCWeak provides a common base class for enabling reference counting on other classes via inheritance. It delegates the actual reference count tracking to the RCImpl implementation specified as a template parameter. It also disables copy but enables move.
Nested classes are used to facilitate the requirements of weak pointers and those classes are documented seperately. The member functions just delegate to the refcount_ object that's injected via template, with the previously mentionend nested classes changing the way ref counts work as required.
typedef RCPtr<RCWeak> openvpn::RCWeak< RCImpl >::Ptr |
typedef RCWeakPtr<RCWeak> openvpn::RCWeak< RCImpl >::WPtr |
|
inlinenoexcept |
|
virtualdefault |
|
delete |
|
delete |
|
friend |
Helper to increment a ref count.
R | type that has an incrementable member refcount_ |
rcptr | pointer to instance of R |
Helper function template to implement incrementing of a member 'refcount_' of a type R; acts as an adapter layer to implement this funtionality as well as some conditionally built debug logging.
|
friend |
Helper to decrement a ref count.
R | type that has an decrementable member refcount_ |
rcptr | pointer to instance of R |
Helper function template to implement decrementing of a member 'refcount_' of a type R; acts as an adapter layer to implement this funtionality as well as some conditionally built debug logging and a conditionally built notify hook.
|
private |