Maintains a reference count safely in a multithreaded environment.
More...
#include <rw/pointer/RWAtomicCounter.h>
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;
}
RWAtomicCounter::RWAtomicCounter |
( |
unsigned |
n = 0 | ) |
|
|
inline |
Constructs a default instance that initializes the reference count. Throws no exceptions.
Constructs a static instance that does not initialize the reference count. Throws no exceptions.
Default-initializes the internal count to zero.
unsigned RWAtomicCounter::addReference |
( |
void |
| ) |
|
|
inline |
Increments the reference count and then returns the previous value minus one.
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.