Sharded atomic counter.
More...
|
template<size_t COUNT> |
void | inc (Shards< COUNT > &shards, size_t id) |
| Increment the counter of a shard by 1. More...
|
|
template<size_t COUNT> |
void | add (Shards< COUNT > &shards, size_t id, size_t n) |
| Increment the counter for a shard by n. More...
|
|
template<size_t COUNT> |
Type | get (const Shards< COUNT > &shards, size_t id) |
| Get the counter value for a shard. More...
|
|
template<size_t COUNT> |
void | for_each (const Shards< COUNT > &shards, Function &&f) |
| Iterate over the shards. More...
|
|
template<size_t COUNT> |
Type | total (const Shards< COUNT > &shards) |
| Get the total value of all shards. More...
|
|
template<size_t COUNT> |
void | clear (Shards< COUNT > &shards) |
| Clear the counter - reset to 0. More...
|
|
◆ Function
◆ Pad
◆ Shards
template<size_t COUNT = 128>
◆ Type
◆ add()
template<size_t COUNT>
void Counter::add |
( |
Shards< COUNT > & |
shards, |
|
|
size_t |
id, |
|
|
size_t |
n |
|
) |
| |
|
inline |
Increment the counter for a shard by n.
- Parameters
-
[in,out] | shards | Sharded counter to increment. |
[in] | id | Shard key. |
[in] | n | Number to add. |
◆ clear()
template<size_t COUNT>
void Counter::clear |
( |
Shards< COUNT > & |
shards | ) |
|
|
inline |
Clear the counter - reset to 0.
- Parameters
-
[in,out] | shards | Shards to clear. |
◆ for_each()
template<size_t COUNT>
void Counter::for_each |
( |
const Shards< COUNT > & |
shards, |
|
|
Function && |
f |
|
) |
| |
|
inline |
Iterate over the shards.
- Parameters
-
[in] | shards | Shards to iterate over |
[in] | f | Callback function |
- Returns
- total value.
◆ get()
template<size_t COUNT>
Type Counter::get |
( |
const Shards< COUNT > & |
shards, |
|
|
size_t |
id |
|
) |
| |
|
inline |
Get the counter value for a shard.
- Parameters
-
[in,out] | shards | Sharded counter to increment. |
[in] | id | Shard key. |
◆ inc()
template<size_t COUNT>
void Counter::inc |
( |
Shards< COUNT > & |
shards, |
|
|
size_t |
id |
|
) |
| |
|
inline |
Increment the counter of a shard by 1.
- Parameters
-
[in,out] | shards | Sharded counter to increment. |
[in] | id | Shard key. |
◆ total()
template<size_t COUNT>
Type Counter::total |
( |
const Shards< COUNT > & |
shards | ) |
|
|
inline |
Get the total value of all shards.
- Parameters
-
- Returns
- total value.