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

A bucket of memory blocks of the given size. More...

Public Member Functions

 Bucket ()=delete
 
 Bucket (std::size_t bucket_size, std::size_t block_size)
 Creates the bucket. More...
 
 Bucket (const Bucket &)=delete
 
 Bucket (Bucket &&) noexcept
 
Bucketoperator= (const Bucket &)=delete
 
Bucketoperator= (Bucket &&)=delete
 
 ~Bucket ()
 
std::size_t bucket_size () const noexcept
 Size of the whole bucket. More...
 
std::size_t block_count () const noexcept
 Number of memory blocks in this bucket. More...
 
std::size_t block_size () const noexcept
 Size of a single block of memory. More...
 
std::size_t blocks_free () const noexcept
 Number of unused blocks. More...
 
std::size_t is_empty () const noexcept
 Whether all blocks are unused. More...
 
std::size_t is_full () const noexcept
 Whether all blocks are being used. More...
 
std::bytememory () const noexcept
 Pointer to the memory held by this bucket. More...
 
bool contains (const void *ptr) const noexcept
 Whether this bucket contains the given pointer. More...
 
void * allocate (std::size_t bytes) noexcept
 Allocates the given number of bytes. More...
 
void deallocate (void *ptr, std::size_t bytes) noexcept
 Deallocates the given number of bytes. More...
 

Private Attributes

const std::size_t bucket_size_
 
const std::size_t block_count_
 
const std::size_t block_size_
 
std::size_t blocks_free_
 
std::bytememory_
 
Strategy allocator_
 

Friends

bool operator== (const Bucket &l, const Bucket &r) noexcept
 Compares two buckets. More...
 

Detailed Description

template<class Strategy>
class mysql_harness::SecureMemoryPool::Bucket< Strategy >

A bucket of memory blocks of the given size.

Constructor & Destructor Documentation

◆ Bucket() [1/4]

template<class Strategy >
mysql_harness::SecureMemoryPool::Bucket< Strategy >::Bucket ( )
delete

◆ Bucket() [2/4]

template<class Strategy >
mysql_harness::SecureMemoryPool::Bucket< Strategy >::Bucket ( std::size_t  bucket_size,
std::size_t  block_size 
)

Creates the bucket.

Parameters
bucket_sizeSize of the whole bucket.
block_sizeSize of a single block of memory.

◆ Bucket() [3/4]

template<class Strategy >
mysql_harness::SecureMemoryPool::Bucket< Strategy >::Bucket ( const Bucket< Strategy > &  )
delete

◆ Bucket() [4/4]

template<class Strategy >
mysql_harness::SecureMemoryPool::Bucket< Strategy >::Bucket ( Bucket< Strategy > &&  b)
noexcept

◆ ~Bucket()

template<class Strategy >
mysql_harness::SecureMemoryPool::Bucket< Strategy >::~Bucket ( )

Member Function Documentation

◆ allocate()

template<class Strategy >
void * mysql_harness::SecureMemoryPool::Bucket< Strategy >::allocate ( std::size_t  bytes)
noexcept

Allocates the given number of bytes.

Parameters
bytesNumber of bytes to allocate.
Returns
Allocated memory or nullptr if bucket cannot allocate the requested amount of memory.

◆ block_count()

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::block_count ( ) const
inlinenoexcept

Number of memory blocks in this bucket.

◆ block_size()

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::block_size ( ) const
inlinenoexcept

Size of a single block of memory.

◆ blocks_free()

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::blocks_free ( ) const
inlinenoexcept

Number of unused blocks.

◆ bucket_size()

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::bucket_size ( ) const
inlinenoexcept

Size of the whole bucket.

◆ contains()

template<class Strategy >
bool mysql_harness::SecureMemoryPool::Bucket< Strategy >::contains ( const void *  ptr) const
noexcept

Whether this bucket contains the given pointer.

◆ deallocate()

template<class Strategy >
void mysql_harness::SecureMemoryPool::Bucket< Strategy >::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.

◆ is_empty()

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::is_empty ( ) const
inlinenoexcept

Whether all blocks are unused.

◆ is_full()

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::is_full ( ) const
inlinenoexcept

Whether all blocks are being used.

◆ memory()

template<class Strategy >
std::byte * mysql_harness::SecureMemoryPool::Bucket< Strategy >::memory ( ) const
inlinenoexcept

Pointer to the memory held by this bucket.

◆ operator=() [1/2]

template<class Strategy >
Bucket & mysql_harness::SecureMemoryPool::Bucket< Strategy >::operator= ( Bucket< Strategy > &&  )
delete

◆ operator=() [2/2]

template<class Strategy >
Bucket & mysql_harness::SecureMemoryPool::Bucket< Strategy >::operator= ( const Bucket< Strategy > &  )
delete

Friends And Related Function Documentation

◆ operator==

template<class Strategy >
bool operator== ( const Bucket< Strategy > &  l,
const Bucket< Strategy > &  r 
)
friend

Compares two buckets.

Member Data Documentation

◆ allocator_

template<class Strategy >
Strategy mysql_harness::SecureMemoryPool::Bucket< Strategy >::allocator_
private

◆ block_count_

template<class Strategy >
const std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::block_count_
private

◆ block_size_

template<class Strategy >
const std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::block_size_
private

◆ blocks_free_

template<class Strategy >
std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::blocks_free_
private

◆ bucket_size_

template<class Strategy >
const std::size_t mysql_harness::SecureMemoryPool::Bucket< Strategy >::bucket_size_
private

◆ memory_

template<class Strategy >
std::byte* mysql_harness::SecureMemoryPool::Bucket< Strategy >::memory_
private

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