MySQL 9.0.0
Source Code Documentation
Atomic_xor_of_things< T_thing, T_digit > Class Template Reference

A class to allow any trivially copyable object to be XOR'ed. More...

#include <os0thread.h>

Public Member Functions

 Atomic_xor_of_things ()
 
void xor_thing (T_thing id)
 
T_thing recover_if_single ()
 Returns an object that was XOR'ed odd number of times. More...
 

Private Attributes

std::array< std::atomic< T_digit >, digits_countacc
 

Static Private Attributes

static constexpr size_t digits_count
 

Detailed Description

template<typename T_thing, typename T_digit>
class Atomic_xor_of_things< T_thing, T_digit >

A class to allow any trivially copyable object to be XOR'ed.

Trivially copyable according to https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable means we can copy the underlying representation to array of chars, and back and consider it a valid copy. It is thread-safe when changing, but no modifications must be assured during reading the stored value.

Constructor & Destructor Documentation

◆ Atomic_xor_of_things()

template<typename T_thing , typename T_digit >
Atomic_xor_of_things< T_thing, T_digit >::Atomic_xor_of_things ( )
inline

Member Function Documentation

◆ recover_if_single()

template<typename T_thing , typename T_digit >
T_thing Atomic_xor_of_things< T_thing, T_digit >::recover_if_single ( )
inline

Returns an object that was XOR'ed odd number of times.

This function assumes there is exactly one such object, and caller must assure this. This method is not thread-safe and caller must ensure no other thread is trying to modify the value.

◆ xor_thing()

template<typename T_thing , typename T_digit >
void Atomic_xor_of_things< T_thing, T_digit >::xor_thing ( T_thing  id)
inline

Member Data Documentation

◆ acc

template<typename T_thing , typename T_digit >
std::array<std::atomic<T_digit>, digits_count> Atomic_xor_of_things< T_thing, T_digit >::acc
private

◆ digits_count

template<typename T_thing , typename T_digit >
constexpr size_t Atomic_xor_of_things< T_thing, T_digit >::digits_count
staticconstexprprivate
Initial value:
=
(sizeof(T_thing) + sizeof(T_digit) - 1) / sizeof(T_digit)

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