Async++ unknown
Async (co_await/co_return) code for C++
Loading...
Searching...
No Matches
asyncpp::intrusive_refcount< T, TCounter > Class Template Reference

Intrusive refcounting base class. More...

#include <asyncpp/ref.h>

Protected Member Functions

size_t use_count () const noexcept
 Get the current use_count of this object.
 
void add_ref () const noexcept
 Increment the reference count.
 
void remove_ref () const noexcept
 Decrement the reference count and delete the object if the last reference is removed.
 

Friends

void refcounted_add_ref (const intrusive_refcount< T, TCounter > *ptr) noexcept
 
void refcounted_remove_ref (const intrusive_refcount< T, TCounter > *ptr) noexcept
 

Detailed Description

template<typename T, RefCount TCounter>
class asyncpp::intrusive_refcount< T, TCounter >

Intrusive refcounting base class.

Template Parameters
TDerived type
TCounterCounter policy to use, e.g. thread_safe_refcount or thread_unsafe_refcount

Member Function Documentation

◆ remove_ref()

template<typename T , RefCount TCounter>
void asyncpp::intrusive_refcount< T, TCounter >::remove_ref ( ) const
inlineprotectednoexcept

Decrement the reference count and delete the object if the last reference is removed.

Note
This might invoke the equivalent of delete (T*)this. Make sure you do not access any member data after calling unless you hold an extra reference to it.

◆ use_count()

template<typename T , RefCount TCounter>
size_t asyncpp::intrusive_refcount< T, TCounter >::use_count ( ) const
inlineprotectednoexcept

Get the current use_count of this object.

Returns
size_t The reference count

The documentation for this class was generated from the following file: