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

A stateless RawAllocator that allocates memory using the virtual memory allocation functions. More...

#include <wpi/memory/virtual_memory.hpp>

Public Types

using is_stateful = std::false_type
 

Public Member Functions

 virtual_memory_allocator () noexcept=default
 
 virtual_memory_allocator (virtual_memory_allocator &&) noexcept
 
 ~virtual_memory_allocator () noexcept=default
 
virtual_memory_allocatoroperator= (virtual_memory_allocator &&) noexcept
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void deallocate_node (void *node, std::size_t size, std::size_t alignment) noexcept
 
std::size_t max_node_size () const noexcept
 
std::size_t max_alignment () const noexcept
 

Detailed Description

A stateless RawAllocator that allocates memory using the virtual memory allocation functions.

It does not prereserve any memory and will always reserve and commit combined.

Member Typedef Documentation

◆ is_stateful

Constructor & Destructor Documentation

◆ virtual_memory_allocator() [1/2]

wpi::memory::virtual_memory_allocator::virtual_memory_allocator ( )
defaultnoexcept

◆ virtual_memory_allocator() [2/2]

wpi::memory::virtual_memory_allocator::virtual_memory_allocator ( virtual_memory_allocator && )
inlinenoexcept

◆ ~virtual_memory_allocator()

wpi::memory::virtual_memory_allocator::~virtual_memory_allocator ( )
defaultnoexcept

Member Function Documentation

◆ allocate_node()

void * wpi::memory::virtual_memory_allocator::allocate_node ( std::size_t size,
std::size_t alignment )
Effects:
A RawAllocator allocation function. It uses virtual_memory_reserve followed by virtual_memory_commit for the allocation. The number of pages allocated will be the minimum to hold size continuous bytes, i.e. size will be rounded up to the next multiple. If debug fences are activated, one additional page before and after the memory will be allocated.
Returns:
A pointer to a node, it will never be nullptr. It will always be aligned on a fence boundary, regardless of the alignment parameter.
Throws:
An exception of type out_of_memory or whatever is thrown by its handler if the allocation fails.

◆ deallocate_node()

void wpi::memory::virtual_memory_allocator::deallocate_node ( void * node,
std::size_t size,
std::size_t alignment )
noexcept
Effects:
A RawAllocator deallocation function. It calls virtual_memory_decommit followed by virtual_memory_release for the deallocation.

◆ max_alignment()

std::size_t wpi::memory::virtual_memory_allocator::max_alignment ( ) const
noexcept
Returns:
The maximum alignment which is the same as the virtual_memory_page_size.

◆ max_node_size()

std::size_t wpi::memory::virtual_memory_allocator::max_node_size ( ) const
noexcept
Returns:
The maximum node size by returning the maximum value.

◆ operator=()

virtual_memory_allocator & wpi::memory::virtual_memory_allocator::operator= ( virtual_memory_allocator && )
inlinenoexcept

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