bit::memory
Public Member Functions | Private Member Functions | List of all members
bit::memory::virtual_block_allocator< Pages, GrowthMultiplier > Class Template Reference

This block allocator is used for creating virtual memory blocks. More...

#include <virtual_block_allocator.hpp>

Inheritance diagram for bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >:
bit::memory::ebo_storage< GrowthMultiplier > bit::memory::dynamic_size_type< 0, Pages >

Public Member Functions

template<std::size_t UPages = Pages, typename = std::enable_if_t<UPages!=dynamic_size>>
 virtual_block_allocator (GrowthMultiplier growth=GrowthMultiplier{})
 Constructs a virtual_block_allocator that reserves the specified number of pages up front. More...
 
template<std::size_t UPages = Pages, typename = std::enable_if_t<UPages==dynamic_size>>
 virtual_block_allocator (std::size_t pages, GrowthMultiplier growth=GrowthMultiplier{})
 Constructs a virtual_block_allocator that reserves the specified number of pages up front. More...
 
 virtual_block_allocator (virtual_block_allocator &&other) noexcept
 Move-constructs a virtual_block_allocator from another one. More...
 
 virtual_block_allocator (const virtual_block_allocator &other)=delete
 
 ~virtual_block_allocator ()
 Destructs this virtual_block_allocator, decommitting any commit pages.
 
virtual_block_allocatoroperator= (virtual_block_allocator &&other)=delete
 
virtual_block_allocatoroperator= (const virtual_block_allocator &other)=delete
 
owner< memory_blockallocate_block () noexcept
 Allocates a memory_block of size block_size. More...
 
void deallocate_block (owner< memory_block > block) noexcept
 Deallocates a given memory_block. More...
 
std::size_t next_block_size () const noexcept
 Queries the next block size expected from this allocator. More...
 
allocator_info info () const noexcept
 Gets the info about this allocator. More...
 

Private Member Functions

constexpr std::size_t value () const noexcept
 Retrieves the value. More...
 

Detailed Description

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
class bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >

This block allocator is used for creating virtual memory blocks.

This allocator reserves virtual memory pages up front, and commits them as they get requested. Any blocks that get deleted are simply cached for later use, rather than being decommitted each time.

Satisfies
BlockAllocator

Definition at line 64 of file virtual_block_allocator.hpp.

Constructor & Destructor Documentation

◆ virtual_block_allocator() [1/3]

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
template<std::size_t UPages = Pages, typename = std::enable_if_t<UPages!=dynamic_size>>
bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::virtual_block_allocator ( GrowthMultiplier  growth = GrowthMultiplier{})
explicit

Constructs a virtual_block_allocator that reserves the specified number of pages up front.

Parameters
growththe growth multiplier

◆ virtual_block_allocator() [2/3]

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
template<std::size_t UPages = Pages, typename = std::enable_if_t<UPages==dynamic_size>>
bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::virtual_block_allocator ( std::size_t  pages,
GrowthMultiplier  growth = GrowthMultiplier{} 
)
explicit

Constructs a virtual_block_allocator that reserves the specified number of pages up front.

Parameters
pagesthe number of pages to reserve
growththe growth multiplier

◆ virtual_block_allocator() [3/3]

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::virtual_block_allocator ( virtual_block_allocator< Pages, GrowthMultiplier > &&  other)
noexcept

Move-constructs a virtual_block_allocator from another one.

Parameters
otherthe other virtual_block_allocator to move

Member Function Documentation

◆ allocate_block()

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
owner<memory_block> bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::allocate_block ( )
noexcept

Allocates a memory_block of size block_size.

Returns
a newly allocated memory_block

◆ deallocate_block()

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
void bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::deallocate_block ( owner< memory_block block)
noexcept

Deallocates a given memory_block.

Parameters
blockthe block to deallocate

◆ info()

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
allocator_info bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::info ( ) const
noexcept

Gets the info about this allocator.

This defaults to 'virtual_block_allocator'. Use a named_virtual_block_allocator to override this

Returns
the info for this allocator

◆ next_block_size()

template<std::size_t Pages, typename GrowthMultiplier = no_growth_multiplier>
std::size_t bit::memory::virtual_block_allocator< Pages, GrowthMultiplier >::next_block_size ( ) const
noexcept

Queries the next block size expected from this allocator.

Returns
the size of the next allocated block

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