---
name: "AtomicCounter"
section: "3cc"
platform: "linux"
package: "libcommoncpp2-dev"
version: "1.0.13-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/AtomicCounter"
---

# AtomicCounter(3cc)

The AtomicCounter class offers thread-safe manipulation of an integer counter. atomic counter operation.

## NAME

AtomicCounter - The AtomicCounter class offers thread-safe manipulation of an integer counter. atomic counter operation.

## SYNOPSIS

`#include <thread.h>`

### Public Methods

**AtomicCounter** ()\
 *Initialize an atomic counter to 0.* **AtomicCounter** (int value)\
 *Initialize an atomic counter to a known value.* int **operator++** (void)\
 int **operator--** (void)\
 int **operator+=** (int change)\
 int **operator-=** (int change)\
 int **operator+** (int change)\
 int **operator-** (int change)\
 int **operator=** (int value)\
 bool **operator!** (void)\
 **operator int** ()\

## DETAILED DESCRIPTION

The AtomicCounter class offers thread-safe manipulation of an integer counter. atomic counter operation.

These are commonly used for building thread-safe 'reference' counters for C++ classes. The AtomicCounter depends on the platforms support for 'atomic' integer operations, and can alternately substitute a 'mutex' if no atomic support exists.

**Author:**  Sean Cavanaugh \<sean@dimensionalrift.com\>

## CONSTRUCTOR & DESTRUCTOR DOCUMENTATION

### AtomicCounter::AtomicCounter ()

Initialize an atomic counter to 0.

### AtomicCounter::AtomicCounter (int value)

Initialize an atomic counter to a known value.

**Parameters:**

- *value*

  *initial value.*

## MEMBER FUNCTION DOCUMENTATION

### AtomicCounter::operator int ()

### bool AtomicCounter::operator! (void)

### int AtomicCounter::operator+ (int change)

### int AtomicCounter::operator++ (void)

### int AtomicCounter::operator+= (int change)

### int AtomicCounter::operator- (int change)

### int AtomicCounter::operator-- (void)

### int AtomicCounter::operator-= (int change)

### int AtomicCounter::operator= (int value)

## AUTHOR

*Generated automatically by Doxygen for CommonC++ from the source code.*
