bit::memory
Public Types | Public Member Functions | List of all members
bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable > Class Template Reference

This block allocator uses policies to modify the behaviour of the underlying type. More...

#include <policy_block_allocator.hpp>

Inheritance diagram for bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >:
bit::memory::ebo_storage< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >

Public Types

using lock_type = BasicLockable
 
using tracker_type = MemoryTracker
 

Public Member Functions

 policy_block_allocator ()=default
 Default-constructs the policy_block_allocator.
 
template<typename Arg0 , typename... Args, typename = std::enable_if_t< std::is_constructible<BlockAllocator,Arg0,Args...>::value && !std::is_same<Arg0,std::decay_t<policy_block_allocator>>::value>>
 policy_block_allocator (Arg0 &&arg0, Args &&...args)
 Constructs the underlying block allocator by forwarding the arguments to it. More...
 
 policy_block_allocator (policy_block_allocator &&other)=default
 Move-constructs this policy_block_allocator from an existing one. More...
 
 policy_block_allocator (const policy_block_allocator &other)=default
 Copy-constructs this policy_block_allocator from an existing one. More...
 
 ~policy_block_allocator ()
 Destructs the policy_block_allocator, finalizing any leak tracking.
 
policy_block_allocatoroperator= (policy_block_allocator &&other)=default
 Move-assigns this policy_block_allocator from an existing one. More...
 
policy_block_allocatoroperator= (const policy_block_allocator &other)=default
 Copy-assigns this policy_block_allocator from an existing one. More...
 
owner< memory_blockallocate_block ()
 Allocates a memory block using the underliny allocator. More...
 
void deallocate_block (owner< memory_block > block)
 Deallocates the specified memory block. More...
 
const tracker_type & tracker () const noexcept
 Accesses the tracker from the arena_allocator. More...
 
allocator_info info () const noexcept
 Gets the info about this current block allocator, or null otherwise. More...
 
std::size_t next_block_size () const noexcept
 Queries the next block size expected from this allocator. More...
 

Detailed Description

template<typename BlockAllocator, typename MemoryTagger, typename MemoryTracker, typename BasicLockable>
class bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >

This block allocator uses policies to modify the behaviour of the underlying type.

This block allocator acts and behaves identically to the underlying BlockAllocator by proxying the same functions defined in the BlockAllocator concept.

Note
Even if all policies satisfy the Stateless concept, this allocator will always be considered stateful since it delegates actions in its destructor – which may call a function that touches external state (which is thus no longer stateless).
Satisfies
BlockAllocator
Template Parameters
BlockAllocatorThe block allocator to use
MemoryTaggerA class used for tagging memory on allocations and on deallocations.
MemoryTrackerA class used for tracking memory allocations.
BoundsCheckerA class used for bounds checking; used to catch buffer-overflow issues
BasicLockableA lockable type for thread-synchronization

Definition at line 101 of file policy_block_allocator.hpp.

Constructor & Destructor Documentation

◆ policy_block_allocator() [1/3]

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
template<typename Arg0 , typename... Args, typename = std::enable_if_t< std::is_constructible<BlockAllocator,Arg0,Args...>::value && !std::is_same<Arg0,std::decay_t<policy_block_allocator>>::value>>
bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::policy_block_allocator ( Arg0 &&  arg0,
Args &&...  args 
)

Constructs the underlying block allocator by forwarding the arguments to it.

Parameters
argsthe arguments to forward to the underlying block allocator

◆ policy_block_allocator() [2/3]

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::policy_block_allocator ( policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable > &&  other)
default

Move-constructs this policy_block_allocator from an existing one.

Note
this is only enabled if the underlying allocator supports it
Parameters
otherthe other allocator to move

◆ policy_block_allocator() [3/3]

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::policy_block_allocator ( const policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable > &  other)
default

Copy-constructs this policy_block_allocator from an existing one.

Note
this is only enabled if the underlying allocator supports it
Parameters
otherthe other allocator to copy

Member Function Documentation

◆ allocate_block()

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
owner<memory_block> bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::allocate_block ( )

Allocates a memory block using the underliny allocator.

Returns
the allocated block

◆ deallocate_block()

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
void bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::deallocate_block ( owner< memory_block block)

Deallocates the specified memory block.

Parameters
blockthe block to deallocate

◆ info()

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
allocator_info bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::info ( ) const
noexcept

Gets the info about this current block allocator, or null otherwise.

Note
This is only enabled if the underlying BlockAllocator supports info()
Returns
the allocator info

◆ next_block_size()

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
std::size_t bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::next_block_size ( ) const
noexcept

Queries the next block size expected from this allocator.

Returns
the size of the next allocated block

◆ operator=() [1/2]

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
policy_block_allocator& bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::operator= ( policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable > &&  other)
default

Move-assigns this policy_block_allocator from an existing one.

Note
this is only enabled if the underlying allocator supports it
Parameters
otherthe other allocator to move
Returns
reference to (*this)

◆ operator=() [2/2]

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
policy_block_allocator& bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::operator= ( const policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable > &  other)
default

Copy-assigns this policy_block_allocator from an existing one.

Note
this is only enabled if the underlying allocator supports it
Parameters
otherthe other allocator to copy
Returns
reference to (*this)

◆ tracker()

template<typename BlockAllocator , typename MemoryTagger , typename MemoryTracker , typename BasicLockable >
const tracker_type& bit::memory::policy_block_allocator< BlockAllocator, MemoryTagger, MemoryTracker, BasicLockable >::tracker ( ) const
noexcept

Accesses the tracker from the arena_allocator.

Returns
the tracker

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