A singleton‐per‐tag relaxed counter.

Synopsis

Declared in <folly/concurrency/SingletonRelaxedCounter.h>

template<
    typename Int,
    typename Tag>
class SingletonRelaxedCounter;

Description

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.

Static Member Functions

Name

Description

add

Adds a value to the counter.

count

Computes the current value of the counter.

sub

Subtracts a value from the counter.

Template Parameters

Name

Description

Int

The integral counter type.

Tag

A tag type selecting which counter instance to use.

Created with MrDocs