Qore Programming Language 2.0.0
Loading...
Searching...
No Matches
QoreReferenceCounter Class Reference

Provides atomic reference counting to Qore objects. More...

#include <QoreReferenceCounter.h>

Inheritance diagram for QoreReferenceCounter:
[legend]

Public Member Methods

DLLEXPORT QoreReferenceCounter ()
 Creates the reference counter object.
 
DLLEXPORT QoreReferenceCounter (const QoreReferenceCounter &old)
 Creates a new object with a reference count of 1.
 
DLLEXPORT ~QoreReferenceCounter ()
 destroys the reference counter object
 
DLLEXPORT bool is_unique () const
 Returns true if the reference count is 1.
 
DLLEXPORT bool optRef ()
 Make a strong reference only if the object is valid.
 
DLLEXPORT int reference_count () const
 Gets the reference count.
 
DLLEXPORT bool ROdereference () const
 Atomically decrements the reference count.
 
DLLEXPORT void ROreference () const
 Atomically increments the reference count.
 

Detailed Description

Provides atomic reference counting to Qore objects.

Constructor & Destructor Documentation

◆ QoreReferenceCounter()

DLLEXPORT QoreReferenceCounter::QoreReferenceCounter ( const QoreReferenceCounter old)

Creates a new object with a reference count of 1.

Since
Qore 0.8.12.9

Member Function Documentation

◆ is_unique()

DLLEXPORT bool QoreReferenceCounter::is_unique ( ) const

Returns true if the reference count is 1.

Returns
returns true if the reference count is 1

Referenced by QoreListNodeEvalOptionalRefHolder::canEdit().

◆ optRef()

DLLEXPORT bool QoreReferenceCounter::optRef ( )

Make a strong reference only if the object is valid.

Returns
true if the reference was made (current reference count > 0), in which case a ROdereference() operation must also be made when releasing the object
Note
This function only makes sense in case this class is used for a strong reference count and there is a valid (externally-tracked) weak reference count for the object

◆ reference_count()

DLLEXPORT int QoreReferenceCounter::reference_count ( ) const

Gets the reference count.

Returns
returns the current reference count

◆ ROdereference()

DLLEXPORT bool QoreReferenceCounter::ROdereference ( ) const

Atomically decrements the reference count.

returns true if the reference count is now zero

Returns
true if the reference count is now zero

Referenced by AbstractPrivateData::deref(), DataLineIterator::deref(), FileLineIterator::deref(), InputStreamLineIterator::deref(), AbstractPrivateData::deref(), and ResolvedCallReferenceNode::weakDeref().


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