A reference counter that keeps per-thread counts to avoid contention.
Declared in <folly/concurrency/memory/TLRefCount.h>
class TLRefCount;
The count is maintained in thread-local sub-counters while in the local phase, then folded into a single global atomic counter once useGlobal() is called. This makes increments and decrements cheap in the common case.
| Name | Description |
|---|---|
Int | The signed integer type used for the count. |
| Name | Description |
|---|---|
TLRefCount [constructor] | Constructs the counter in the local phase with an initial count of one. |
~TLRefCount [destructor] | Destroys the counter; requires the global count to have reached zero. |
operator* | Reads the current reference count. |
operator++ | Increments the reference count. |
operator-- | Decrements the reference count. |
useGlobal | Switches this counter to the global phase. |
| Name | Description |
|---|---|
useGlobal | Switches several counters to the global phase together. |