memory
|
A RawAllocator adapter that tracks another allocator using a tracker.
It wraps another RawAllocator and calls the tracker function before forwarding to it. The class can then be used anywhere a RawAllocator is required and the memory usage will be tracked.
If the RawAllocator uses deeply_tracked_block_allocator as BlockAllocator, it will also track growth and shrinking of the allocator.
Typedefs | |
using | allocator_type = typename allocator_traits< RawAllocator >::allocator_type |
using | tracker = Tracker |
using | is_stateful = std::integral_constant< bool, traits::is_stateful::value||!std::is_empty< Tracker >::value > |
Member Functions | |
~tracked_allocator () noexcept | |
void * | allocate_node (std::size_t size, std::size_t alignment) |
void * | try_allocate_node (std::size_t size, std::size_t alignment) noexcept |
void * | allocate_array (std::size_t count, std::size_t size, std::size_t alignment) |
void * | try_allocate_array (std::size_t count, std::size_t size, std::size_t alignment) noexcept |
void | deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept |
bool | try_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 |
bool | try_deallocate_array (void *ptr, std::size_t count, std::size_t size, std::size_t alignment) noexcept |
tracked_allocator (tracker t={}) noexcept | |
tracked_allocator (tracker t, allocator_type &&allocator) noexcept | |
tracked_allocator (tracked_allocator &&other) noexcept | |
tracked_allocator & | operator= (tracked_allocator &&other) noexcept |
std::size_t | max_node_size () const |
std::size_t | max_array_size () const |
std::size_t | max_alignment () const |
allocator_type & | get_allocator () noexcept |
const allocator_type & | get_allocator () const noexcept |
tracker & | get_tracker () noexcept |
const tracker & | get_tracker () const noexcept |
Related Functions | |
template<class Tracker , class RawAllocator > | |
auto | make_tracked_allocator (Tracker t, RawAllocator &&alloc) -> tracked_allocator< Tracker, typename std::decay< RawAllocator >::type > |
|
explicitnoexcept |
Tracker::on_allocator_growth()
function.
|
noexcept |
Tracker::on_allocator_growth()
function.
|
noexcept |
Tracker::on_allocator_shrinking()
function.
|
noexcept |
|
noexcept |
void * allocate_node | ( | std::size_t | size, |
std::size_t | alignment | ||
) |
Tracker::on_node_allocation()
and forwards to the allocator. If a growth occurs and the allocator is deeply tracked, also calls Tracker::on_allocator_growth()
. allocate_node()
|
noexcept |
Tracker::on_node_allocation()
. try_allocate_node()
. void * allocate_array | ( | std::size_t | count, |
std::size_t | size, | ||
std::size_t | alignment | ||
) |
Tracker::on_array_allocation()
and forwards to the allocator. If a growth occurs and the allocator is deeply tracked, also calls Tracker::on_allocator_growth()
. allocate_array()
|
noexcept |
Tracker::on_array_allocation()
. try_allocate_array()
.
|
noexcept |
Tracker::on_node_deallocation()
and forwards to the allocator's deallocate_node()
. If shrinking occurs and the allocator is deeply tracked, also calls Tracker::on_allocator_shrinking()
.
|
noexcept |
Tracker::on_node_deallocation()
. try_deallocate_node()
.
|
noexcept |
Tracker::on_array_deallocation()
and forwards to the allocator's deallocate_array()
. If shrinking occurs and the allocator is deeply tracked, also calls Tracker::on_allocator_shrinking()
.
|
noexcept |
Tracker::on_array_deallocation()
. try_deallocate_array()
. std::size_t max_node_size | ( | ) | const |
std::size_t max_array_size | ( | ) | const |
std::size_t max_alignment | ( | ) | const |
|
noexcept |
const
) reference to the wrapped allocator.
|
noexcept |
const
) reference to the wrapped allocator.
|
noexcept |
const
) reference to the tracker.
|
noexcept |
const
) reference to the tracker.
|
related |