SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWAtomicCounter Class Reference

Maintains a reference count safely in a multithreaded environment. More...

#include <rw/pointer/RWAtomicCounter.h>

Public Member Functions

 RWAtomicCounter ()
 
 RWAtomicCounter (const RWAtomicCounter &)
 
 RWAtomicCounter (RWStaticCtor)
 
 RWAtomicCounter (unsigned n)
 
unsigned addReference (void)
 
RWAtomicCounteroperator= (const RWAtomicCounter &)
 
unsigned references (void) const
 
unsigned removeReference (void)
 

Detailed Description

RWAtomicCounter maintains a reference count and can safely be used in a multithreaded environment.

Example
#include <rw/pointer/RWAtomicCounter.h>
#include <rw/pointer/RWTCountingPointer.h>
int main() {
return 0;
}
Defines a reference-counted pointer that provides reference counting semantics for types that do not ...
Definition RWTCountingPointer.h:64

Constructor & Destructor Documentation

◆ RWAtomicCounter() [1/4]

RWAtomicCounter::RWAtomicCounter ( )
inline

Constructs an RWAtomicCounter with initial reference count set to 0. Throws no exceptions.

◆ RWAtomicCounter() [2/4]

RWAtomicCounter::RWAtomicCounter ( unsigned n)
inlineexplicit

Constructs an RWAtomicCounter with initial reference count set to n. Throws no exceptions.

◆ RWAtomicCounter() [3/4]

RWAtomicCounter::RWAtomicCounter ( RWStaticCtor )
inline

Constructs a static instance that does not initialize the reference count. Throws no exceptions.

◆ RWAtomicCounter() [4/4]

RWAtomicCounter::RWAtomicCounter ( const RWAtomicCounter & )
inline

Default-initializes the internal count to zero.

Member Function Documentation

◆ addReference()

unsigned RWAtomicCounter::addReference ( void )
inline

Increments the reference count and then returns the previous value minus one.

◆ operator=()

RWAtomicCounter & RWAtomicCounter::operator= ( const RWAtomicCounter & )
inline

Copy assignment operator that does nothing, allowing derived classes to do assignments. Returns *this.

◆ references()

unsigned RWAtomicCounter::references ( void ) const
inline

Queries the current reference count. Throws no exceptions.

◆ removeReference()

unsigned RWAtomicCounter::removeReference ( void )
inline

Decrements the reference count and then returns the previous value minus one.

Copyright © 2025 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.