A singleton-per-tag relaxed counter.
Declared in <folly/concurrency/SingletonRelaxedCounter.h>
template<
typename Int,
typename Tag>
class SingletonRelaxedCounter;
It is optimized for increment/decrement performance under contention. Each unique pair of integral type and tag type names a distinct counter. The value is computed by summing a global counter and all per-thread counters, so it is a relaxed approximation rather than a point-in-time snapshot; it is exact once the system quiesces. For unsigned types, decrements are assumed not to exceed increments and any observed excess is ignored.
| Name | Description |
|---|---|
add | Adds a value to the counter. |
count | Computes the current value of the counter. |
sub | Subtracts a value from the counter. |
| Name | Description |
|---|---|
| Int | The integral counter type. |
| Tag | A tag type selecting which counter instance to use. |