ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::ZeroPageAllocator< T > Class Template Reference

an allocator of objects of type T on blocks of 0s, aligned to a huge page if they fill one at least [see the file] More...

#include <ADS/memory/HugePageAllocator.h>

Public types

using value_type = T
 the objects
using is_zeroed = void
 the blocks are all 0 bits [see PointerTable.h]

Public member functions

 ZeroPageAllocator (void)=default
 the allocator, which has no state
template<class U>
 ZeroPageAllocator (const ZeroPageAllocator< U > &) noexcept
 the allocator of objects of type T, from that of type U
T * allocate (std::size_t n)
 room for \( n \) objects, all 0 bits: a block of \( b \) bytes of std::calloc() if \( b \) is less than a huge page, the place aligned to a huge page in one of \( b \) bytes, a huge page and a pointer, which holds the block, otherwise
void deallocate (T *p, std::size_t n) noexcept
 the room \( p \) of \( n \) objects given back to the system
template<class U>
bool operator== (const ZeroPageAllocator< U > &) const noexcept
 true: the allocators are all equal

Static public attributes

static constexpr std::size_t PAGE = std::size_t( 1 ) << 21
 the size of a huge page, in bytes

Detailed description

template<class T>
class ADS::ZeroPageAllocator< T >

an allocator of objects of type T on blocks of 0s, aligned to a huge page if they fill one at least [see the file]

Member typedef documentation

◆ is_zeroed

template<class T>
using ADS::ZeroPageAllocator< T >::is_zeroed = void

the blocks are all 0 bits [see PointerTable.h]

◆ value_type

template<class T>
using ADS::ZeroPageAllocator< T >::value_type = T

the objects

Constructor and destructor documentation

◆ ZeroPageAllocator() [1/2]

template<class T>
ADS::ZeroPageAllocator< T >::ZeroPageAllocator ( void )
default

the allocator, which has no state

◆ ZeroPageAllocator() [2/2]

template<class T>
template<class U>
ADS::ZeroPageAllocator< T >::ZeroPageAllocator ( const ZeroPageAllocator< U > & )
inlinenoexcept

the allocator of objects of type T, from that of type U

Member function documentation

◆ allocate()

template<class T>
T * ADS::ZeroPageAllocator< T >::allocate ( std::size_t n)
inlinenodiscard

room for \( n \) objects, all 0 bits: a block of \( b \) bytes of std::calloc() if \( b \) is less than a huge page, the place aligned to a huge page in one of \( b \) bytes, a huge page and a pointer, which holds the block, otherwise

◆ deallocate()

template<class T>
void ADS::ZeroPageAllocator< T >::deallocate ( T * p,
std::size_t n )
inlinenoexcept

the room \( p \) of \( n \) objects given back to the system

Precondition
\( p \) was given by allocate( n )

◆ operator==()

template<class T>
template<class U>
bool ADS::ZeroPageAllocator< T >::operator== ( const ZeroPageAllocator< U > & ) const
inlinenoexcept

true: the allocators are all equal

Member data documentation

◆ PAGE

template<class T>
std::size_t ADS::ZeroPageAllocator< T >::PAGE = std::size_t( 1 ) << 21
staticconstexpr

the size of a huge page, in bytes


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