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

#include <segregator.hpp>

Inherits SmallAllocator, and LargeAllocator.

Public Types

using small_allocator = SmallAllocator
 
using large_allocator = LargeAllocator
 

Public Member Functions

block allocate (size_t n) noexcept
 
void deallocate (block &b) noexcept
 
bool reallocate (block &b, size_t n) noexcept
 
template<typename U = SmallAllocator, typename V = LargeAllocator>
std::enable_if
< traits::has_expand
< SmallAllocator >::value||traits::has_expand
< LargeAllocator >::value,
bool >::type 
expand (block &b, size_t delta) noexcept
 
template<typename U = SmallAllocator, typename V = LargeAllocator>
std::enable_if
< traits::has_expand
< SmallAllocator >::value||traits::has_expand
< LargeAllocator >::value,
bool >::type 
owns (const block &b) const noexcept
 
template<typename U = SmallAllocator, typename V = LargeAllocator>
std::enable_if
< traits::has_expand
< SmallAllocator >::value||traits::has_expand
< LargeAllocator >::value,
void >::type 
deallocate_all () noexcept
 

Static Public Attributes

static constexpr size_t threshold = Threshold
 
static constexpr bool supports_truncated_deallocation
 
static constexpr unsigned alignment
 

Detailed Description

template<size_t Threshold, class SmallAllocator, class LargeAllocator>
class alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >

This allocator separates the allocation requested depending on a threshold between the Small- and the LargeAllocator

Template Parameters
ThresholdThe edge until all allocations go to the SmallAllocator
SmallAllocatorThis gets all allocations below the Threshold
LargeAllocatorThis gets all allocations starting with the Threshold

Definition at line 27 of file segregator.hpp.

Member Function Documentation

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
block alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::allocate ( size_t  n)
inlinenoexcept

Allocates the specified number of bytes. If the operation was not successful it returns an empty block.

Parameters
nNumber of requested bytes
Returns
Block with the memory information.

Definition at line 53 of file segregator.hpp.

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
void alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::deallocate ( block b)
inlinenoexcept

Frees the given block and resets it.

Parameters
bThe block to be freed.

Definition at line 70 of file segregator.hpp.

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
template<typename U = SmallAllocator, typename V = LargeAllocator>
std::enable_if<traits::has_expand<SmallAllocator>::value || traits::has_expand<LargeAllocator>::value, void>::type alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::deallocate_all ( )
inlinenoexcept

Deallocates all memory. This is available if one of the allocators implement it.

Definition at line 161 of file segregator.hpp.

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
template<typename U = SmallAllocator, typename V = LargeAllocator>
std::enable_if<traits::has_expand<SmallAllocator>::value || traits::has_expand<LargeAllocator>::value, bool>::type alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::expand ( block b,
size_t  delta 
)
inlinenoexcept

The given block will be expanded insito This method is only available if one the Allocators implements it.

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

Definition at line 118 of file segregator.hpp.

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
template<typename U = SmallAllocator, typename V = LargeAllocator>
std::enable_if<traits::has_expand<SmallAllocator>::value || traits::has_expand<LargeAllocator>::value, bool>::type alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::owns ( const block b) const
inlinenoexcept

Checks the ownership of the given block. This is only available if both Allocator implement it

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

Definition at line 146 of file segregator.hpp.

Member Data Documentation

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
constexpr unsigned alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::alignment
static
Initial value:
=
(SmallAllocator::alignment > LargeAllocator::alignment) ?
SmallAllocator::alignment : LargeAllocator::alignment

Definition at line 42 of file segregator.hpp.

template<size_t Threshold, class SmallAllocator , class LargeAllocator >
constexpr bool alb::v_100::segregator< Threshold, SmallAllocator, LargeAllocator >::supports_truncated_deallocation
static
Initial value:
=
SmallAllocator::supports_truncated_deallocation &&
LargeAllocator::supports_truncated_deallocation

Definition at line 38 of file segregator.hpp.


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