Allocator Builder
Policy Based C++ Template Allocator Library
 All Classes Functions Variables Enumerations Enumerator Groups Pages
alb::v_100::cascading_allocator_base< Shared, Allocator > Class Template Reference

#include <cascading_allocator.hpp>

Public Types

using allocator = Allocator
 

Public Member Functions

 cascading_allocator_base (cascading_allocator_base &&x) noexcept
 
cascading_allocator_baseoperator= (cascading_allocator_base &&x) noexcept
 
 ~cascading_allocator_base ()
 
block allocate (size_t n) noexcept
 
void deallocate (block &b) noexcept
 
bool reallocate (block &b, size_t n) noexcept
 
template<typename U = Allocator>
std::enable_if
< traits::has_expand< U >
::value, bool >::type 
expand (block &b, size_t delta) noexcept
 
bool owns (const block &b) const noexcept
 
template<typename U = Allocator>
std::enable_if
< traits::has_deallocate_all
< U >::value, void >::type 
deallocate_all () noexcept
 

Static Public Member Functions

static constexpr size_t good_size (size_t n)
 

Static Public Attributes

static constexpr bool supports_truncated_deallocation = Allocator::supports_truncated_deallocation
 
static constexpr unsigned alignment = Allocator::alignment
 

Detailed Description

template<bool Shared, typename Allocator>
class alb::v_100::cascading_allocator_base< Shared, Allocator >

This implements a cascade of allocators. If the first allocator cannot fulfill the given request, then a next one is created and the requested is passed to it. This class is thread safe as far as not deleteAll is called.

Template Parameters
Allocatorof this type Allocators get created.

Definition at line 29 of file cascading_allocator.hpp.

Constructor & Destructor Documentation

template<bool Shared, typename Allocator>
alb::v_100::cascading_allocator_base< Shared, Allocator >::~cascading_allocator_base ( )
inline

Frees all allocated memory!

Definition at line 183 of file cascading_allocator.hpp.

Member Function Documentation

template<bool Shared, typename Allocator>
block alb::v_100::cascading_allocator_base< Shared, Allocator >::allocate ( size_t  n)
inlinenoexcept

Sends the request to the first allocator, if it cannot fulfill the request then the next Allocator is created and so on

Definition at line 192 of file cascading_allocator.hpp.

template<bool Shared, typename Allocator>
void alb::v_100::cascading_allocator_base< Shared, Allocator >::deallocate ( block b)
inlinenoexcept

Frees the given block and resets it

Definition at line 236 of file cascading_allocator.hpp.

template<bool Shared, typename Allocator>
template<typename U = Allocator>
std::enable_if<traits::has_deallocate_all<U>::value, void>::type alb::v_100::cascading_allocator_base< Shared, Allocator >::deallocate_all ( )
inlinenoexcept

Deletes all allocated resources. All Blocks created by this instance must not be used any more. Calling this method while other threads are allocating or deallocating leads to unpredictable behavior. This is only available if the Allocator implements it as well.

Definition at line 315 of file cascading_allocator.hpp.

template<bool Shared, typename Allocator>
template<typename U = Allocator>
std::enable_if<traits::has_expand<U>::value, bool>::type alb::v_100::cascading_allocator_base< Shared, Allocator >::expand ( block b,
size_t  delta 
)
inlinenoexcept

Tries to expand the given block insito by the specified number of bytes This is only available if the Allocator implements it

Parameters
bThe block to be expanded
deltaThe amount of bytes
Returns
True, if the operation was successful

Definition at line 288 of file cascading_allocator.hpp.

template<bool Shared, typename Allocator>
bool alb::v_100::cascading_allocator_base< Shared, Allocator >::owns ( const block b) const
inlinenoexcept

Checks for the ownership of the given block

Parameters
bThe block to check
Returns
True, if one of the allocator owns it.

Definition at line 302 of file cascading_allocator.hpp.

template<bool Shared, typename Allocator>
bool alb::v_100::cascading_allocator_base< Shared, Allocator >::reallocate ( block b,
size_t  n 
)
inlinenoexcept

Reallocates the given block to the specified size. If the owning allocator cannot fulfill the request then a cross move is performed

Parameters
bBlock to be reallocated
nThe new size
True,ifthe operation was successful

Definition at line 261 of file cascading_allocator.hpp.


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