mCRL2
Loading...
Searching...
No Matches
mcrl2::utilities::shared_reference_counted< T, ThreadSafe > Class Template Reference

Stores a reference count that can be incremented and decremented. More...

#include <shared_reference.h>

Public Member Functions

 shared_reference_counted ()
 
std::size_t reference_count () const
 Obtain the reference count.
 
void increment_reference_count () const
 Increment the reference count by one.
 
void decrement_reference_count () const
 Decrement the reference count by one.
 

Static Public Member Functions

static std::atomic< std::size_t > & reference_count_changes ()
 Obtain the number of times that this reference count has changed.
 
static void count_reference_count_changes ()
 Increment the number of reference count changes.
 

Protected Types

using SizeType = typename std::conditional< ThreadSafe, std::atomic< std::size_t >, std::size_t >::type
 

Protected Attributes

SizeType m_reference_count
 

Detailed Description

template<typename T, bool ThreadSafe = false>
class mcrl2::utilities::shared_reference_counted< T, ThreadSafe >

Stores a reference count that can be incremented and decremented.

The template variable is such that reference_count_changes corresponds to the amount of times the reference count of type T changed.

Definition at line 33 of file shared_reference.h.

Member Typedef Documentation

◆ SizeType

template<typename T , bool ThreadSafe = false>
using mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::SizeType = typename std::conditional<ThreadSafe, std::atomic<std::size_t>, std::size_t>::type
protected

Definition at line 91 of file shared_reference.h.

Constructor & Destructor Documentation

◆ shared_reference_counted()

template<typename T , bool ThreadSafe = false>
mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::shared_reference_counted ( )
inline

Definition at line 36 of file shared_reference.h.

Member Function Documentation

◆ count_reference_count_changes()

template<typename T , bool ThreadSafe = false>
static void mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::count_reference_count_changes ( )
inlinestatic

Increment the number of reference count changes.

Definition at line 82 of file shared_reference.h.

◆ decrement_reference_count()

template<typename T , bool ThreadSafe = false>
void mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::decrement_reference_count ( ) const
inline

Decrement the reference count by one.

Definition at line 61 of file shared_reference.h.

◆ increment_reference_count()

template<typename T , bool ThreadSafe = false>
void mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::increment_reference_count ( ) const
inline

Increment the reference count by one.

Definition at line 47 of file shared_reference.h.

◆ reference_count()

template<typename T , bool ThreadSafe = false>
std::size_t mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::reference_count ( ) const
inline

Obtain the reference count.

Definition at line 41 of file shared_reference.h.

◆ reference_count_changes()

template<typename T , bool ThreadSafe = false>
static std::atomic< std::size_t > & mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::reference_count_changes ( )
inlinestatic

Obtain the number of times that this reference count has changed.

Definition at line 75 of file shared_reference.h.

Member Data Documentation

◆ m_reference_count

template<typename T , bool ThreadSafe = false>
SizeType mcrl2::utilities::shared_reference_counted< T, ThreadSafe >::m_reference_count
mutableprotected

Definition at line 94 of file shared_reference.h.


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