rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWAtomicCounter Class Reference
[Smart Pointers]

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

#include <rw/pointer/RWAtomicCounter.h>

List of all members.

Public Member Functions

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

Detailed Description

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

Examples

 #include <rw/pointer/RWAtomicCounter.h>
 #include <rw/pointer/RWTCountingPointer.h>

 int main()
 {
   RWTCountingPointer<int, RWAtomicCounter> pointer = new int(10);

   return 0;
 }

Constructor & Destructor Documentation

RWAtomicCounter::RWAtomicCounter ( unsigned  n = 0  )  [inline]

Constructs a default instance that initializes the reference count. Throws no exceptions.

RWAtomicCounter::RWAtomicCounter ( RWStaticCtor   )  [inline]

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

RWAtomicCounter::RWAtomicCounter ( const RWAtomicCounter  )  [inline]

Default-initializes the internal count to zero.


Member Function Documentation

unsigned RWAtomicCounter::addReference ( void   )  [inline]

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

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

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

unsigned RWAtomicCounter::references ( void   )  const [inline]

Queries the current reference count. Throws no exceptions.

unsigned RWAtomicCounter::removeReference ( void   )  [inline]

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

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.