CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
booster::atomic_counter Class Reference

Atomic counter is a class that allows perform counting in thread safe way. More...

`#include <booster/booster/atomic_counter.h>`

## Public Member Functions
| atomic_counter (long v)
long | operator++ ()
long | operator-- ()
| operator long () const

## Detailed Description

Atomic counter is a class that allows perform counting in thread safe way.

It is mainly used for reference counting. Under Windows it uses Interlocked API, under other platforms it used built-in atomic operations or fails back to pthreads locking implementation.

Notes:

- This counter is not safe for use in process shared memory, when pthreads fall-back is used
- Under POSIX platform pthread_mutex_t is always present in order to make sure that we can implement or remove pthread fall-back at any point not affecting ABI

## Constructor & Destructor Documentation

booster::atomic_counter::atomic_counter | ( | long | v | ) |
| explicit

Create a counter with initial value v

## Member Function Documentation

booster::atomic_counter::operator long | ( |  | ) | const
| inline

Return current value - atomically

long booster::atomic_counter::operator++ | ( |  | ) |
| inline

Increment and return the result after increment atomically

long booster::atomic_counter::operator-- | ( |  | ) |
| inline

Decrement and return the result after decrement atomically

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

- booster/atomic_counter.h