memory
Typedefs | Static Functions | Member Functions
double_frame_allocator< BlockOrRawAllocator > Class Template Reference

Detailed Description

template<class BlockOrRawAllocator = default_allocator>
class foonathan::memory::double_frame_allocator< BlockOrRawAllocator >

An alias for iteration_allocator for two iterations.

Typedefs

using allocator_type = detail::iteration_block_allocator< default_allocator >
 

Static Functions

static std::size_t max_iterations () noexcept
 

Member Functions

void * allocate (std::size_t size, std::size_t alignment)
 
void * try_allocate (std::size_t size, std::size_t alignment) noexcept
 
void next_iteration () noexcept
 
std::size_t cur_iteration () const noexcept
 
allocator_type & get_allocator () noexcept
 
std::size_t capacity_left (std::size_t i) const noexcept
 
std::size_t capacity_left () const noexcept
 

Member Functions

◆ allocate()

void * allocate ( std::size_t  size,
std::size_t  alignment 
)
inherited
Effects:
Allocates a memory block of given size and alignment. It simply moves the top marker of the currently active stack.
Returns:
A node with given size and alignment.
Throws:
out_of_fixed_memory if the current stack does not have any memory left.
Requires:
size and alignment must be valid.

◆ try_allocate()

void * try_allocate ( std::size_t  size,
std::size_t  alignment 
)
noexceptinherited
Effects:
Allocates a memory block of given size and alignment similar to allocate().
Returns:
A node with given size and alignment or nullptr if the current stack does not have any memory left.

◆ next_iteration()

void next_iteration ( )
noexceptinherited
Effects:
Goes to the next internal stack. This will clear the stack whose max_iterations() lifetime has reached, and use it for all allocations in this iteration.
Note
This function should be called at the end of the loop.

◆ max_iterations()

static std::size_t max_iterations ( )
staticnoexceptinherited
Returns:
The number of iteration each allocation will live. This is the template parameter N.

◆ cur_iteration()

std::size_t cur_iteration ( ) const
noexceptinherited
Returns:
The index of the current iteration. This is modulo max_iterations().

◆ get_allocator()

allocator_type & get_allocator ( )
noexceptinherited
Returns:
A reference to the BlockAllocator used for managing the memory.
Requires:
It is undefined behavior to move this allocator out into another object.

◆ capacity_left() [1/2]

std::size_t capacity_left ( std::size_t  i) const
noexceptinherited
Returns:
The amount of memory remaining in the stack with the given index. This is the number of bytes that are available for allocation.

◆ capacity_left() [2/2]

std::size_t capacity_left ( ) const
noexceptinherited
Returns:
The amount of memory remaining in the currently active stack.