MySQL 8.4.2
Source Code Documentation
ut::PSI_memory_key_t Struct Reference

Light-weight and type-safe wrapper around the PSI_memory_key that eliminates the possibility of introducing silent bugs through the course of implicit conversions and makes them show up as compile-time errors. More...

#include <ut0new.h>

Public Member Functions

 PSI_memory_key_t (PSI_memory_key key)
 
PSI_memory_key operator() () const
 

Public Attributes

PSI_memory_key m_key
 

Detailed Description

Light-weight and type-safe wrapper around the PSI_memory_key that eliminates the possibility of introducing silent bugs through the course of implicit conversions and makes them show up as compile-time errors.

Without this wrapper it was possible to say: aligned_alloc_withkey(10*sizeof(int), key, 64)) Which would unfortunately compile just fine but it would silently introduce a bug because it confuses the order of 10*sizeof(int) and key input arguments. Both of them are unsigned types.

With the wrapper, aligned_alloc_withkey(10*sizeof(int), key, 64)) now results with a compile-time error and the only proper way to accomplish the original intent is to use PSI_memory_key_t wrapper like so: aligned_alloc_withkey(PSI_memory_key_t{key}, 10*sizeof(int), 64))

Or by making use of the convenience function to create one: aligned_alloc_withkey(make_psi_memory_key(key), 10*sizeof(int), 64))

Constructor & Destructor Documentation

◆ PSI_memory_key_t()

ut::PSI_memory_key_t::PSI_memory_key_t ( PSI_memory_key  key)
inlineexplicit

Member Function Documentation

◆ operator()()

PSI_memory_key ut::PSI_memory_key_t::operator() ( void  ) const
inline

Member Data Documentation

◆ m_key

PSI_memory_key ut::PSI_memory_key_t::m_key

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