MySQL 26.10.0
Source Code Documentation
hm::Metric_Buffer< T > Class Template Reference

Metric_Buffer extends the circular buffer, Stat_Buffer, with a two-way read/write capability such that it can be shared between multiple collectors. More...

#include <health_monitor_metric_buffer.h>

Inheritance diagram for hm::Metric_Buffer< T >:
[legend]

Public Member Functions

 Metric_Buffer ()=default
 
 Metric_Buffer (bool no_lock, PSI_memory_key memory_key)
 
 Metric_Buffer (PSI_rwlock_key rwlock_key, PSI_memory_key memory_key)
 
bool writeable ()
 
void set_writeable (bool writeable)
 
int write (const T &record)
 
template<typename U >
auto write (const U &arg) -> std::enable_if_t< std::is_constructible_v< T, U >, int >
 
- Public Member Functions inherited from hm::Stat_Buffer< T >
 Stat_Buffer ()=default
 
 Stat_Buffer (bool no_lock, PSI_memory_key memory_key)
 
 Stat_Buffer (PSI_rwlock_key rwlock_key, PSI_memory_key memory_key)
 
virtual ~Stat_Buffer ()
 
 Stat_Buffer (const Stat_Buffer &)=default
 
Stat_Buffer & operator= (const Stat_Buffer &)=default
 
 Stat_Buffer (Stat_Buffer &&) noexcept=default
 
Stat_Buffer & operator= (Stat_Buffer &&) noexcept=default
 
int read (T &record, unsigned int row_num)
 Read an element of the stat buffer. More...
 
int read_last (T &record)
 Read the last element of the stat buffer. More...
 
int lock_read ()
 Acquire a read lock for a shared buffer. More...
 
void unlock ()
 Unlock a read or write lock for a shared buffer. More...
 
int read_no_lock (T &record, unsigned int row_num)
 Read an element from the circular buffer by logical row index. More...
 
int read_impl (T &record, size_t row_num)
 
int write (const T &record)
 Write one element into the circular buffer at the current head position. More...
 
int write_impl (const T &record)
 
void resize (size_t new_size)
 Resize the stat buffer, preserve the most recent data. More...
 
void resize_impl (size_t new_size)
 
void reset ()
 Reset the state of the buffer. More...
 
void reset_no_lock ()
 Reset the buffer. More...
 
void reset_impl ()
 
bool map_logical_to_row_no_lock (uint64_t logical_idx, int &row_out) const
 Map a global logical index to the current ring-buffer row. More...
 
bool map_logical_to_row (uint64_t logical_idx, int &row_out) const
 
bool map_logical_to_row_impl (uint64_t logical_idx, int &row_out) const
 
mysql_rwlock_t * get_rwlock ()
 
size_t max_size () const
 
size_t index () const
 
size_t count () const
 
size_t total_written () const
 
bool full () const
 
bool wrapped () const
 

Private Attributes

std::atomic< bool > m_writeable {false}
 

Additional Inherited Members

- Protected Attributes inherited from hm::Stat_Buffer< T >
std::unique_ptr< std::vector< T, Allocator > > m_stats {nullptr}
 
size_t m_max_size {0}
 
size_t m_index {0}
 
size_t m_count {0}
 
size_t m_total_written {0}
 
bool m_full {false}
 
bool m_wrapped {false}
 
bool m_no_lock {false}
 
PSI_rwlock_key m_rwlock_key {0}
 
mysql_rwlock_t m_rwlock
 
PSI_memory_key m_memory_key {0}
 

Detailed Description

template<typename T>
class hm::Metric_Buffer< T >

Metric_Buffer extends the circular buffer, Stat_Buffer, with a two-way read/write capability such that it can be shared between multiple collectors.

Constructor & Destructor Documentation

◆ Metric_Buffer() [1/3]

template<typename T >
hm::Metric_Buffer< T >::Metric_Buffer ( )
default

◆ Metric_Buffer() [2/3]

template<typename T >
hm::Metric_Buffer< T >::Metric_Buffer ( bool  no_lock,
PSI_memory_key  memory_key 
)
inline

◆ Metric_Buffer() [3/3]

template<typename T >
hm::Metric_Buffer< T >::Metric_Buffer ( PSI_rwlock_key  rwlock_key,
PSI_memory_key  memory_key 
)
inline

Member Function Documentation

◆ set_writeable()

template<typename T >
void hm::Metric_Buffer< T >::set_writeable ( bool  writeable)
inline

◆ write() [1/2]

template<typename T >
int hm::Metric_Buffer< T >::write ( const T &  record)
inline

◆ write() [2/2]

template<typename T >
template<typename U >
auto hm::Metric_Buffer< T >::write ( const U &  arg) -> std::enable_if_t<std::is_constructible_v<T, U>, int>
inline

◆ writeable()

template<typename T >
bool hm::Metric_Buffer< T >::writeable ( )
inline

Member Data Documentation

◆ m_writeable

template<typename T >
std::atomic<bool> hm::Metric_Buffer< T >::m_writeable {false}
private

The documentation for this class was generated from the following file: