MySQL  8.0.18
Source Code Documentation
ut0counter.h File Reference

Counter utility class. More...

#include <my_rdtsc.h>
#include "univ.i"
#include "os0thread.h"
#include "ut0dbg.h"
#include <array>
#include <atomic>
#include <functional>

Go to the source code of this file.


struct  generic_indexer_t< Type, N >
 Get the offset into the counter array. More...
struct  counter_indexer_t< Type, N >
 Use the result of my_timer_cycles(), which mainly uses RDTSC for cycles, to index into the counter array. More...
struct  single_indexer_t< Type, N >
 For counters where N=1. More...
class  ib_counter_t< Type, N, Indexer >
 Class for using fuzzy counters. More...
struct  Counter::Shard
 Counter shard. More...


 Sharded atomic counter.


 CPU cache line size. More...
#define IB_N_SLOTS   64
 Default number of slots to use in ib_counter_t. More...
#define default_indexer_t   counter_indexer_t


using Counter::Type = uint64_t
using Counter::N = std::atomic< Type >
using Counter::Pad = byte[INNOBASE_CACHE_LINE_SIZE - sizeof(N)]
template<size_t COUNT = 128>
using Counter::Shards = std::array< Shard, COUNT >
using Counter::Function = std::function< void(const Type)>


template<size_t COUNT>
void Counter::inc (Shards< COUNT > &shards, size_t id)
 Increment the counter of a shard by 1. More...
template<size_t COUNT>
void Counter::add (Shards< COUNT > &shards, size_t id, size_t n)
 Increment the counter for a shard by n. More...
template<size_t COUNT>
Type Counter::get (const Shards< COUNT > &shards, size_t id)
 Get the counter value for a shard. More...
template<size_t COUNT>
void Counter::for_each (const Shards< COUNT > &shards, Function &&f)
 Iterate over the shards. More...
template<size_t COUNT>
Type Counter::total (const Shards< COUNT > &shards)
 Get the total value of all shards. More...
template<size_t COUNT>
void Counter::clear (Shards< COUNT > &shards)
 Clear the counter - reset to 0. More...

Detailed Description

Counter utility class.

Created 2012/04/12 by Sunny Bains

Macro Definition Documentation

◆ default_indexer_t

#define default_indexer_t   counter_indexer_t


#define IB_N_SLOTS   64

Default number of slots to use in ib_counter_t.



CPU cache line size.