MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mysql_harness::SecureMemoryPool::BucketPool< BucketType > Class Template Referencefinal

Holds buckets with the given block size. More...

Classes

struct  BucketHash
 

Public Member Functions

 BucketPool ()=delete
 
 BucketPool (std::size_t page_size, std::size_t block_size)
 Creates the pool. More...
 
 BucketPool (const BucketPool &)=delete
 
 BucketPool (BucketPool &&)=delete
 
BucketPooloperator= (const BucketPool &)=delete
 
BucketPooloperator= (BucketPool &&)=delete
 
 ~BucketPool ()=default
 
std::size_t page_size () const noexcept
 Page size for the buckets in this pool. More...
 
std::size_t block_size () const noexcept
 Size of a single block of memory. More...
 
void * allocate (std::size_t bytes)
 Allocates the given number of bytes. More...
 
void deallocate (void *ptr, std::size_t bytes) noexcept
 Deallocates the given number of bytes. More...
 

Private Types

using Buckets = std::unordered_set< BucketType, BucketHash >
 

Private Member Functions

BucketType * add_bucket (std::size_t size)
 
void remove_bucket (BucketType *bucket)
 
BucketType * find_bucket (const void *ptr)
 Finds the bucket which holds the given memory address. More...
 

Static Private Member Functions

static BucketType * pointer (Buckets::const_iterator it)
 

Private Attributes

const std::size_t page_size_
 
const std::size_t block_size_
 
std::mutex mutex_
 
Buckets buckets_
 
Buckets full_buckets_
 
std::unordered_map< const void *, BucketType * > memory_map_
 
const BucketType * empty_bucket_
 

Detailed Description

template<class BucketType>
class mysql_harness::SecureMemoryPool::BucketPool< BucketType >

Holds buckets with the given block size.

Member Typedef Documentation

◆ Buckets

template<class BucketType >
using mysql_harness::SecureMemoryPool::BucketPool< BucketType >::Buckets = std::unordered_set<BucketType, BucketHash>
private

Constructor & Destructor Documentation

◆ BucketPool() [1/4]

template<class BucketType >
mysql_harness::SecureMemoryPool::BucketPool< BucketType >::BucketPool ( )
delete

◆ BucketPool() [2/4]

template<class BucketType >
mysql_harness::SecureMemoryPool::BucketPool< BucketType >::BucketPool ( std::size_t  page_size,
std::size_t  block_size 
)

Creates the pool.

Parameters
page_sizePage size for the buckets in this pool, size of each bucket is going to be a factor of this size.
block_sizeBlocks size for the buckets in this pool.

◆ BucketPool() [3/4]

template<class BucketType >
mysql_harness::SecureMemoryPool::BucketPool< BucketType >::BucketPool ( const BucketPool< BucketType > &  )
delete

◆ BucketPool() [4/4]

template<class BucketType >
mysql_harness::SecureMemoryPool::BucketPool< BucketType >::BucketPool ( BucketPool< BucketType > &&  )
delete

◆ ~BucketPool()

template<class BucketType >
mysql_harness::SecureMemoryPool::BucketPool< BucketType >::~BucketPool ( )
default

Member Function Documentation

◆ add_bucket()

template<class BucketType >
BucketType * mysql_harness::SecureMemoryPool::BucketPool< BucketType >::add_bucket ( std::size_t  size)
private

◆ allocate()

template<class BucketType >
void * mysql_harness::SecureMemoryPool::BucketPool< BucketType >::allocate ( std::size_t  bytes)

Allocates the given number of bytes.

Parameters
bytesNumber of bytes to allocate.
Returns
Allocated memory.

◆ block_size()

template<class BucketType >
std::size_t mysql_harness::SecureMemoryPool::BucketPool< BucketType >::block_size ( ) const
inlinenoexcept

Size of a single block of memory.

◆ deallocate()

template<class BucketType >
void mysql_harness::SecureMemoryPool::BucketPool< BucketType >::deallocate ( void *  ptr,
std::size_t  bytes 
)
noexcept

Deallocates the given number of bytes.

Parameters
ptrMemory previously allocated by this class.
bytesSize of the memory.

◆ find_bucket()

template<class BucketType >
BucketType * mysql_harness::SecureMemoryPool::BucketPool< BucketType >::find_bucket ( const void *  ptr)
private

Finds the bucket which holds the given memory address.

◆ operator=() [1/2]

template<class BucketType >
BucketPool & mysql_harness::SecureMemoryPool::BucketPool< BucketType >::operator= ( BucketPool< BucketType > &&  )
delete

◆ operator=() [2/2]

template<class BucketType >
BucketPool & mysql_harness::SecureMemoryPool::BucketPool< BucketType >::operator= ( const BucketPool< BucketType > &  )
delete

◆ page_size()

template<class BucketType >
std::size_t mysql_harness::SecureMemoryPool::BucketPool< BucketType >::page_size ( ) const
inlinenoexcept

Page size for the buckets in this pool.

◆ pointer()

template<class BucketType >
static BucketType * mysql_harness::SecureMemoryPool::BucketPool< BucketType >::pointer ( Buckets::const_iterator  it)
inlinestaticprivate

◆ remove_bucket()

template<class BucketType >
void mysql_harness::SecureMemoryPool::BucketPool< BucketType >::remove_bucket ( BucketType *  bucket)
private

Member Data Documentation

◆ block_size_

template<class BucketType >
const std::size_t mysql_harness::SecureMemoryPool::BucketPool< BucketType >::block_size_
private

◆ buckets_

template<class BucketType >
Buckets mysql_harness::SecureMemoryPool::BucketPool< BucketType >::buckets_
private

◆ empty_bucket_

template<class BucketType >
const BucketType* mysql_harness::SecureMemoryPool::BucketPool< BucketType >::empty_bucket_
private

◆ full_buckets_

template<class BucketType >
Buckets mysql_harness::SecureMemoryPool::BucketPool< BucketType >::full_buckets_
private

◆ memory_map_

template<class BucketType >
std::unordered_map<const void *, BucketType *> mysql_harness::SecureMemoryPool::BucketPool< BucketType >::memory_map_
private

◆ mutex_

template<class BucketType >
std::mutex mysql_harness::SecureMemoryPool::BucketPool< BucketType >::mutex_
private

◆ page_size_

template<class BucketType >
const std::size_t mysql_harness::SecureMemoryPool::BucketPool< BucketType >::page_size_
private

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