Documentation of memory

( foonathan/memory)

tracked_impl_allocator< Tracker, ImplRawAllocator > Class Template Reference

Detailed Description

template<class Tracker, class ImplRawAllocator>
class foonathan::memory::tracked_impl_allocator< Tracker, ImplRawAllocator >

A RawAllocator adapter that tracks an implementation allocator.

It wraps a RawAllocator that will be used as implementation allocator inside an arena. Any allocation and deallocation will forward to the growth and shrinking functions of the deep tracker. The class can then be passed as implementation allocator to an arena.

Note
It is recommended to use this class only with tracked_allocator::make_deeply_tracked_allocator.

Typedefs

using allocator_type = typename traits::allocator_type
 
using tracker = Tracker
 
using is_stateful = std::true_type
 

Member Functions

 tracked_impl_allocator (tracker &t, allocator_type allocator={})
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void * allocate_array (std::size_t count, std::size_t size, std::size_t alignment)
 
void deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept
 
void deallocate_array (void *ptr, std::size_t count, std::size_t size, std::size_t alignment) noexcept
 
std::size_t max_node_size () const
 
std::size_t max_array_size () const
 
std::size_t max_alignment () const
 

Constructors

tracked_impl_allocator ( tracker &  t,
allocator_type  allocator = {} 
)
Effects:
Takes a deep tracker and the RawAllocator and wraps it. It will only store a pointer to the Trakcer to allow it being shared with the higher-level arena it is embedded in.

Member Functions

void* allocate_node ( std::size_t  size,
std::size_t  alignment 
)
Effects:
Forwards to the allocation function of the implementation allocator and calls the Tracker::on_allocator_growth() function.
Returns:
The result of the implementation allocator function.
void* allocate_array ( std::size_t  count,
std::size_t  size,
std::size_t  alignment 
)
Effects:
Forwards to the allocation function of the implementation allocator and calls the Tracker::on_allocator_growth() function.
Returns:
The result of the implementation allocator function.
void deallocate_node ( void *  ptr,
std::size_t  size,
std::size_t  alignment 
)
noexcept
Effects:
Forwards to the deallocation function of the implementation allocator after caling the Tracker::on_allocator_shrinking() function.
void deallocate_array ( void *  ptr,
std::size_t  count,
std::size_t  size,
std::size_t  alignment 
)
noexcept
Effects:
Forwards to the deallocation function of the implementation allocator after caling the Tracker::on_allocator_shrinking() function.
std::size_t max_node_size ( ) const
Returns:
The result of the corresponding function the implementation allocator.
std::size_t max_array_size ( ) const
Returns:
The result of the corresponding function the implementation allocator.
std::size_t max_alignment ( ) const
Returns:
The result of the corresponding function the implementation allocator.