![]() |
MySQL 26.10.0
Source Code Documentation
|
Sample data buffer. More...
#include <health_monitor_stat_buffer.h>
Public Member Functions | |
| 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 |
Protected Attributes | |
| 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} |
Private Types | |
| using | Allocator = Component_malloc_allocator< T > |
Sample data buffer.
|
private |
|
default |
|
inline |
|
inline |
|
inlinevirtual |
|
default |
|
defaultnoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Acquire a read lock for a shared buffer.
|
inline |
|
inline |
|
inline |
Map a global logical index to the current ring-buffer row.
This helper translates a monotonically increasing logical sample index (e.g. a global “next_metric”) into a window-relative row index [0..count-1] for the current contents of the buffer.
A logical index is considered “available” if it refers to an element that is still retained in the buffer (not yet overwritten.) If the logical index is older than the oldest existing element or newer than the most recent one, the mapping fails and the function returns false.
Thread safety:
| [in] | logical_idx | Global monotonically increasing sample index. |
| [out] | row_out | On success, the row index in the range [0, count()) that corresponds to logical_idx. |
row_out with read(record, row_out) to retrieve the element.
|
inline |
|
default |
|
defaultnoexcept |
|
inline |
Read an element of the stat buffer.
| [in,out] | record | Element from the buffer to be returned |
| [in] | row_num | Row number, zero-based |
|
inline |
|
inline |
Read the last element of the stat buffer.
| [in,out] | record | Element from the buffer to be returned |
|
inline |
Read an element from the circular buffer by logical row index.
The buffer holds up to m_count valid elements. This function accepts a row non-negative row_num range [0, m_count].
Thread safety:
| [out] | record | On success, set to element at requested logical row. |
| [in] | row_num | Zero-based logical row index [0, m_count]. |
|
inline |
Reset the state of the buffer.
Existing elements will be overwritten.
|
inline |
|
inline |
Reset the buffer.
Assumes an active read_lock() if the buffer is shared.
|
inline |
Resize the stat buffer, preserve the most recent data.
Note that m_stats is preallocated to m_max_size elements, so m_stats->size() is always the maximum size.
| [in] | new_size | Desired size of the buffer, can be either larger or smaller than the current size |
|
inline |
|
inline |
|
inline |
Unlock a read or write lock for a shared buffer.
|
inline |
|
inline |
Write one element into the circular buffer at the current head position.
If the buffer is not yet full, the element is appended logically and the valid element count (m_count) increases. The head index (m_index) advances modulo the buffer size.
Once the buffer reaches capacity:
Thread safety:
| [in] | record | Element to write. |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |