Sources Pipelines Documentation

Allocators  
Public Member Functions | List of all members
boost::memory::fallback_allocator< primary_allocator, secondary_allocator > Class Template Referencefinal

Allocates with secondary allocator, if allocation with primary allocator fails. More...

#include <fallback_allocator.hpp>

Public Member Functions

memory_block allocate (std::size_t size)
 Allocates a memory_block with either primary_allocator or secondary_allocator. More...
 
void deallocate (memory_block &block)
 Deallocates the given memory_block. More...
 
bool owns (memory_block &block)
 Examines if the given block is owned by this allocator. More...
 
primary_allocator & get_primary () noexcept
 
secondary_allocator & get_secondary () noexcept
 

Detailed Description

template<typename primary_allocator, typename secondary_allocator>
class boost::memory::fallback_allocator< primary_allocator, secondary_allocator >

Allocates with secondary allocator, if allocation with primary allocator fails.

This type of allocator allows construction of allocator chains, where allocation is automatically passed over to the secondary allocator in event the primary allocation cannot succeed due to conditions imposed on the allocator.

Template Parameters
primary_allocatorThe primary allocator type to be used.
secondary_allocatorThe secondary allocator type to be used.

Definition at line 27 of file fallback_allocator.hpp.

Member Function Documentation

template<typename primary_allocator , typename secondary_allocator >
memory_block boost::memory::fallback_allocator< primary_allocator, secondary_allocator >::allocate ( std::size_t  size)
inline

Allocates a memory_block with either primary_allocator or secondary_allocator.

An allocation through fallback_allocator at first attempts to allocate requested block with primary_allocator. Should it fail, allocation with secondary_allocator is exercised.
If both backing allocator fail to allocate desired block, a null_block is returned.
Parameters
sizeDesired size of the newly allocated block.
Returns
memory_block non-equal to null_block if allocation was successful, or null_block otherwise.

Definition at line 13 of file fallback_allocator.ipp.

template<typename primary_allocator , typename secondary_allocator >
void boost::memory::fallback_allocator< primary_allocator, secondary_allocator >::deallocate ( memory_block block)
inline

Deallocates the given memory_block.

The given memory_block is only deallocated if it's owned by either of the backing allocators and should be handled for deallocation to an instance of that allocator.

Parameters
blockThe memory_block to deallocate.

Definition at line 23 of file fallback_allocator.ipp.

template<typename primary_allocator , typename secondary_allocator >
bool boost::memory::fallback_allocator< primary_allocator, secondary_allocator >::owns ( memory_block block)
inline

Examines if the given block is owned by this allocator.

A memory_block is owned by a fallback allocator only if it's owned by either of the backing allocators.

Parameters
blockA memory_block to examine.
Returns
true if the block is owned by the allocator.

Definition at line 32 of file fallback_allocator.ipp.


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