A thread‐safe counter that caches increments in thread‐local storage.
Synopsis
Declared in <folly/ThreadCachedInt.h>
template<
class IntT,
class Tag = IntT>
class ThreadCachedInt;
Member Functions
Name |
Description |
|
Constructors |
|
Deleted copy assignment. |
Returns the current per‐thread cache size. |
|
Adds a value to the counter, using the thread‐local cache. |
|
Pre‐increments the counter (post‐increment is not supported). |
|
Adds a value to the counter. |
|
Pre‐decrements the counter (post‐decrement is not supported). |
|
Subtracts a value from the counter. |
|
Quickly grabs the current value which may not include some cached increments. |
|
Quickly reads and resets current value (doesn't reset cached increments). |
|
Reads the current value plus all the cached increments. Requires grabbing a lock, so this is significantly slower than readFast(). |
|
This function is designed for accumulating into another counter, where you only want to count each increment once. It can still get the count a little off, however, but it should be much better than calling readFull() and set(0) sequentially. |
|
Thread‐safe set function. This is a best effort implementation. In some edge cases, there could be data loss (missing counts) |
|
Sets the per‐thread cache size. |
Created with MrDocs