The Vish Visualization Shell 0.3
Vish
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MemCore::ReferenceCount Class Reference

Base class for thread-safe reference counting. More...

#include <elementary/memcore/ReferenceCount.hpp>

Inheritance diagram for MemCore::ReferenceCount:
A< Object > MemCore::Referer< ReferenceBase< Object > >

Public Member Functions

bool canIncrementStrongRefsEvenMore () const noexcept
 The "extreme unction" state is when a pointer is determined to die sure, and this state is set by the suicide() function.
 
refcount_t get_pointers () const noexcept
 Return the weak reference count, i.e.
 
refcount_t get_refs () const noexcept
 Return the strong reference count, i.e.
 
refcount_t weak_refcount () const noexcept
 Return the weak reference count, i.e.
 

Static Public Attributes

static constexpr refcount_t dead_object_refcount = -111L
 Some unrealistically large value that is used during premature destruction of objects to indicate that they are still alive even though they will be killed soon after.
 
static constexpr refcount_t max_object_refcount = 0x39000000L
 Maximum value that a reference count can reach before it overflows.
 
static constexpr refcount_t null_referencer = -222L
 Magic number to indicate that a reference refers to a non-existent reference, i.e.
 

Protected Member Functions

 ReferenceCount () noexcept
 Initialize reference counts to zero.
 

Protected Attributes

interlocked_t strong_refs
 Strong references.
 
interlocked_t weak_refs
 Weak references.
 

Detailed Description

Base class for thread-safe reference counting.

Member Function Documentation

◆ canIncrementStrongRefsEvenMore()

bool MemCore::ReferenceCount::canIncrementStrongRefsEvenMore ( ) const
inlinenoexcept

The "extreme unction" state is when a pointer is determined to die sure, and this state is set by the suicide() function.

In that state a reference pointer can still be incremented and decremented, but it is prone to die soonish.

◆ get_pointers()

refcount_t MemCore::ReferenceCount::get_pointers ( ) const
inlinenoexcept

Return the weak reference count, i.e.

how many pointers refer to this object.

◆ get_refs()

refcount_t MemCore::ReferenceCount::get_refs ( ) const
inlinenoexcept

Return the strong reference count, i.e.

how many object keep this object alive.

◆ weak_refcount()

refcount_t MemCore::ReferenceCount::weak_refcount ( ) const
inlinenoexcept

Return the weak reference count, i.e.

how many pointers refer to this object.

Member Data Documentation

◆ dead_object_refcount

constexpr refcount_t MemCore::ReferenceCount::dead_object_refcount = -111L
staticconstexpr

Some unrealistically large value that is used during premature destruction of objects to indicate that they are still alive even though they will be killed soon after.

Objects with such a strong reference count value pretty much dead. Magic number to indicate that a reference refers to an object that has already died.

◆ max_object_refcount

constexpr refcount_t MemCore::ReferenceCount::max_object_refcount = 0x39000000L
staticconstexpr

Maximum value that a reference count can reach before it overflows.

Theoretically, this value is like the max number of bits, but here we set it to some smaller, arbitrarily chosen value for debugging purposes. It should still never be reached.

◆ null_referencer

constexpr refcount_t MemCore::ReferenceCount::null_referencer = -222L
staticconstexpr

Magic number to indicate that a reference refers to a non-existent reference, i.e.

the weakptr does not have a control block to oeprate on.

Referenced by MemCore::DynPtr< ObjectBase, ObjectBase >::strong_refs(), and MemCore::DynPtr< ObjectBase, ObjectBase >::weak_refs().