WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::memory::temporary_stack Class Reference

A wrapper around the memory_stack that is used by the temporary_allocator. More...

#include <wpi/memory/temporary_allocator.hpp>

Public Types

using growth_tracker = detail::temporary_block_allocator::growth_tracker
 The type of the handler called when the internal memory_stack grows.
 

Public Member Functions

growth_tracker set_growth_tracker (growth_tracker t) noexcept
 
growth_tracker get_growth_tracker () noexcept
 
 temporary_stack (std::size_t initial_size)
 
std::size_t next_capacity () const noexcept
 

Related Symbols

(Note that these are not member symbols.)

temporary_stackget_temporary_stack (std::size_t initial_size=temporary_stack_initializer::default_stack_size)
 

Detailed Description

A wrapper around the memory_stack that is used by the temporary_allocator.

There should be at least one per-thread.

Member Typedef Documentation

◆ growth_tracker

The type of the handler called when the internal memory_stack grows.

It gets the size of the new block that will be allocated.

Required Behavior:
The handler shall log the growth, throw an exception or aborts the program. If this function does not return, the growth is prevented but the allocator unusable until memory is freed.
Default Behavior:
The default handler does nothing.

Constructor & Destructor Documentation

◆ temporary_stack()

wpi::memory::temporary_stack::temporary_stack ( std::size_t initial_size)
inlineexplicit
Effects:
Creates it with a given initial size of the stack. It can grow if needed, although that is expensive.
Requires:
initial_size must be greater than 0.

Member Function Documentation

◆ get_growth_tracker()

growth_tracker wpi::memory::temporary_stack::get_growth_tracker ( )
inlinenoexcept
Returns:
The current growth_tracker. This is never nullptr.

◆ next_capacity()

std::size_t wpi::memory::temporary_stack::next_capacity ( ) const
inlinenoexcept
Returns:
next_capacity() of the internal memory_stack.

◆ set_growth_tracker()

growth_tracker wpi::memory::temporary_stack::set_growth_tracker ( growth_tracker t)
inlinenoexcept
Effects:
Sets h as the new growth_tracker. A nullptr sets the default growth_tracker. Each thread has its own, separate tracker.
Returns:
The previous growth_tracker. This is never nullptr.

Friends And Related Symbol Documentation

◆ get_temporary_stack()

temporary_stack & get_temporary_stack ( std::size_t initial_size = temporary_stack_initializer::default_stack_size)
related
Effects:
Creates the per-thread temporary_stack with the given initial size, if it wasn't already created.
Returns:
The per-thread temporary_stack.
Requires:
There must be a per-thread temporary stack (WPI_MEMORY_TEMPORARY_STACK_MODE must not be equal to 0).
Note
If WPI_MEMORY_TEMPORARY_STACK_MODE is equal to 1, this function can create the temporary stack. But if there is no temporary_stack_initializer, it won't be destroyed.

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