MySQL 9.0.0
Source Code Documentation
memory Namespace Reference

Namespaces

namespace  traits
 

Classes

class  Aligned_atomic
 Templated class that encapsulates an std::atomic within a byte buffer that is padded to the processor cache-line size. More...
 
class  Aligned_atomic_accessor
 Template that may access Aligned_atomic internals. More...
 
struct  is_allocator
 Struct that allows for checking if T fulfills the Allocator named requirements. More...
 
class  PFS_allocator
 Allocator class for instrumenting allocated memory with Performance Schema keys. More...
 
class  Ref_ptr
 Class that holds the pointer to a variable in a static and non-destructible way. More...
 
class  Unique_ptr
 Smart pointer to hold a unique pointer to a heap allocated memory of type T, constructed using a specific allocator. More...
 

Functions

static size_t _cache_line_size ()
 Calculates and returns the size of the CPU cache line. More...
 
static size_t cache_line_size ()
 
template<typename T >
static size_t _cacheline_for ()
 Retrieves the amount of bytes, multiple of the current cacheline size, needed to store an element of type T. More...
 
template<typename T >
static size_t minimum_cacheline_for ()
 Retrieves the amount of bytes, multiple of the current cacheline size, needed to store an element of type T. More...
 
template<typename T , std::enable_if_t< std::is_array< T >::value > * = nullptr>
Unique_ptr< T, std::nullptr_t > make_unique (size_t size)
 In-place constructs a new unique pointer with no specific allocator and with array type T. More...
 
template<typename T , typename A , std::enable_if_t< std::is_array< T >::value > * = nullptr>
Unique_ptr< T, A > make_unique (A &alloc, size_t size)
 In-place constructs a new unique pointer with a specific allocator and with array type T. More...
 
template<typename T , typename A , typename... Args, std::enable_if_t<!std::is_array< T >::value &&memory::is_allocator< A >::value > * = nullptr>
Unique_ptr< T, A > make_unique (A &alloc, Args &&... args)
 In-place constructs a new unique pointer with a specific allocator and with non-array type T. More...
 
template<typename T , typename... Args, std::enable_if_t<!std::is_array< T >::value > * = nullptr>
Unique_ptr< T, std::nullptr_t > make_unique (Args &&... args)
 In-place constructs a new unique pointer with no specific allocator and with non-array type T. More...
 

Function Documentation

◆ _cache_line_size()

static size_t memory::_cache_line_size ( )
inlinestatic

Calculates and returns the size of the CPU cache line.

Returns
the cache line size

◆ _cacheline_for()

template<typename T >
static size_t memory::_cacheline_for ( )
inlinestatic

Retrieves the amount of bytes, multiple of the current cacheline size, needed to store an element of type T.

This is a non-caching non-thread safe helper function and memory::minimum_cacheline_for should be used instead.

Returns
the amount of bytes, multiple of the current cacheline size, needed to store an element of type T.

◆ cache_line_size()

static size_t memory::cache_line_size ( )
inlinestatic

◆ make_unique() [1/4]

template<typename T , typename A , typename... Args, std::enable_if_t<!std::is_array< T >::value &&memory::is_allocator< A >::value > * = nullptr>
Unique_ptr< T, A > memory::make_unique ( A &  alloc,
Args &&...  args 
)

In-place constructs a new unique pointer with a specific allocator and with non-array type T.

Parameters
allocA reference to the allocator object to use.
argsThe parameters to be used in constructing the instance of T.
Returns
A new instance of unique pointer.

◆ make_unique() [2/4]

template<typename T , typename A , std::enable_if_t< std::is_array< T >::value > * = nullptr>
Unique_ptr< T, A > memory::make_unique ( A &  alloc,
size_t  size 
)

In-place constructs a new unique pointer with a specific allocator and with array type T.

Parameters
allocA reference to the allocator object to use.
sizeThe size of the array to allocate.
Returns
A new instance of unique pointer.

◆ make_unique() [3/4]

template<typename T , typename... Args, std::enable_if_t<!std::is_array< T >::value > * = nullptr>
Unique_ptr< T, std::nullptr_t > memory::make_unique ( Args &&...  args)

In-place constructs a new unique pointer with no specific allocator and with non-array type T.

Parameters
argsThe parameters to be used in constructing the instance of T.
Returns
A new instance of unique pointer.

◆ make_unique() [4/4]

template<typename T , std::enable_if_t< std::is_array< T >::value > * = nullptr>
Unique_ptr< T, std::nullptr_t > memory::make_unique ( size_t  size)

In-place constructs a new unique pointer with no specific allocator and with array type T.

Parameters
sizeThe size of the array to allocate.
Returns
A new instance of unique pointer.

◆ minimum_cacheline_for()

template<typename T >
static size_t memory::minimum_cacheline_for ( )
inlinestatic

Retrieves the amount of bytes, multiple of the current cacheline size, needed to store an element of type T.

This function caches the computed value in a static storage variable and does it in a thread-safe manner.

Returns
the amount of bytes, multiple of the current cacheline size, needed to store an element of type T.