MySQL 26.7.0
Source Code Documentation
mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp > Struct Template Reference

Padded slot for Sync_bounded_queue, aligning the struct to cache line size to minimize false sharing in concurrent access. More...

#include <padded_slot.h>

Public Attributes

T element {}
 The stored element in the queue slot. More...
 
bool validity {false}
 Validity flag: true if the slot contains an element ready for consumption, false if empty. More...
 
Mutex_tp validity_mt
 Mutex protecting access to the element and flags. More...
 
Cv_tp producer_cv
 Condition variable for producers waiting for the slot to become free (full queue). More...
 
Cv_tp consumer_cv
 Condition variable for consumers waiting for the slot to be filled (empty queue). More...
 

Detailed Description

template<typename T, typename Mutex_tp, typename Cv_tp, size_t cache_line_size_tp = hardware_destructive_interference_size>
struct mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp >

Padded slot for Sync_bounded_queue, aligning the struct to cache line size to minimize false sharing in concurrent access.

Holds an element, validity flag, mutex, and condition variables for producer-consumer synchronization. Each slot is padded to prevent adjacent slots from sharing cache lines, reducing contention in multi-threaded environments.

Template Parameters
TElement type.
Mutex_tpMutex type
Cv_tpCondition variable type
cache_line_size_tpPadding size (default: hardware_destructive_interference_size).
See also
Sync_bounded_queue

Member Data Documentation

◆ consumer_cv

template<typename T , typename Mutex_tp , typename Cv_tp , size_t cache_line_size_tp = hardware_destructive_interference_size>
Cv_tp mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp >::consumer_cv

Condition variable for consumers waiting for the slot to be filled (empty queue).

◆ element

template<typename T , typename Mutex_tp , typename Cv_tp , size_t cache_line_size_tp = hardware_destructive_interference_size>
T mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp >::element {}

The stored element in the queue slot.

◆ producer_cv

template<typename T , typename Mutex_tp , typename Cv_tp , size_t cache_line_size_tp = hardware_destructive_interference_size>
Cv_tp mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp >::producer_cv

Condition variable for producers waiting for the slot to become free (full queue).

◆ validity

template<typename T , typename Mutex_tp , typename Cv_tp , size_t cache_line_size_tp = hardware_destructive_interference_size>
bool mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp >::validity {false}

Validity flag: true if the slot contains an element ready for consumption, false if empty.

◆ validity_mt

template<typename T , typename Mutex_tp , typename Cv_tp , size_t cache_line_size_tp = hardware_destructive_interference_size>
Mutex_tp mysql::concurrency::detail::Padded_slot< T, Mutex_tp, Cv_tp, cache_line_size_tp >::validity_mt

Mutex protecting access to the element and flags.


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