STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions
stapl::runtime::ref_counted< T, Deleter > Class Template Reference

Provides a reference counting mechanism for objects that derive from it. More...

Public Member Functions

 ref_counted (Deleter const &d) noexcept
 Creates a new ref_counted with a custom deleter.
 
 ref_counted (Deleter &&d) noexcept
 Creates a new ref_counted with a custom deleter. More...
 
constexpr ref_counted (long count) noexcept
 Creates a new ref_counted with an arbitrary initial count.
 
 ref_counted (long count, Deleter const &d) noexcept
 Creates a new ref_counted with an arbitrary initial count and a custom deleter.
 
 ref_counted (long count, Deleter &&d) noexcept
 Creates a new ref_counted with an arbitrary initial count and a custom deleter. More...
 
void add_ref (long count=1, std::memory_order order=std::memory_order_relaxed) noexcept
 Increases the reference count by count.
 
long remove_ref (long count=1, std::memory_order order=std::memory_order_relaxed) noexcept
 Decreases the reference count by count. More...
 
bool release (std::memory_order order=std::memory_order_relaxed) noexcept
 Decreases the reference count, destroying the object if it reached 0. More...
 
long use_count (std::memory_order order=std::memory_order_relaxed) const noexcept
 
bool unique (std::memory_order order=std::memory_order_relaxed) const noexcept
 

Detailed Description

template<typename T, typename Deleter = std::default_delete<T>>
class stapl::runtime::ref_counted< T, Deleter >

Provides a reference counting mechanism for objects that derive from it.

Template Parameters
TReference counted object type.
DeleterDeleter type.

ref_counted is compatible with boost::intrusive_ptr.

Constructor & Destructor Documentation

◆ ref_counted() [1/2]

template<typename T, typename Deleter = std::default_delete<T>>
stapl::runtime::ref_counted< T, Deleter >::ref_counted ( Deleter &&  d)
explicitnoexcept

Creates a new ref_counted with a custom deleter.

◆ ref_counted() [2/2]

template<typename T, typename Deleter = std::default_delete<T>>
stapl::runtime::ref_counted< T, Deleter >::ref_counted ( long  count,
Deleter &&  d 
)
noexcept

Creates a new ref_counted with an arbitrary initial count and a custom deleter.

Member Function Documentation

◆ remove_ref()

template<typename T, typename Deleter = std::default_delete<T>>
long stapl::runtime::ref_counted< T, Deleter >::remove_ref ( long  count = 1,
std::memory_order  order = std::memory_order_relaxed 
)
noexcept

Decreases the reference count by count.

Returns
The new reference count.

◆ release()

template<typename T, typename Deleter = std::default_delete<T>>
bool stapl::runtime::ref_counted< T, Deleter >::release ( std::memory_order  order = std::memory_order_relaxed)
noexcept

Decreases the reference count, destroying the object if it reached 0.

Warning
If release() returns true, then the object has been destroyed.
Returns
true if the object was destroyed, otherwise false.

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