WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::memory::binary_segregator< Segregatable, RawAllocator > Class Template Reference

A RawAllocator that either uses the Segregatable or the other RawAllocator. More...

#include <wpi/memory/segregator.hpp>

Public Types

using segregatable = Segregatable
 
using segregatable_allocator_type = typename segregatable::allocator_type
 
using fallback_allocator_type = typename allocator_traits<RawAllocator>::allocator_type
 

Public Member Functions

 binary_segregator (segregatable s, fallback_allocator_type fallback=fallback_allocator_type())
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void deallocate_node (void *ptr, 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 deallocate_array (void *array, 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_alignemnt () const
 
segregatable_allocator_typeget_segregatable_allocator () noexcept
 
const segregatable_allocator_typeget_segregatable_allocator () const noexcept
 
fallback_allocator_typeget_fallback_allocator () noexcept
 
const fallback_allocator_typeget_fallback_allocator () const noexcept
 

Detailed Description

template<class Segregatable, class RawAllocator>
class wpi::memory::binary_segregator< Segregatable, RawAllocator >

A RawAllocator that either uses the Segregatable or the other RawAllocator.

It is a faster alternative to fallback_allocator that doesn't require a composable allocator and decides about the allocator to use purely with the Segregatable based on size and alignment.

Member Typedef Documentation

◆ fallback_allocator_type

template<class Segregatable , class RawAllocator >
using wpi::memory::binary_segregator< Segregatable, RawAllocator >::fallback_allocator_type = typename allocator_traits<RawAllocator>::allocator_type

◆ segregatable

template<class Segregatable , class RawAllocator >
using wpi::memory::binary_segregator< Segregatable, RawAllocator >::segregatable = Segregatable

◆ segregatable_allocator_type

template<class Segregatable , class RawAllocator >
using wpi::memory::binary_segregator< Segregatable, RawAllocator >::segregatable_allocator_type = typename segregatable::allocator_type

Constructor & Destructor Documentation

◆ binary_segregator()

template<class Segregatable , class RawAllocator >
wpi::memory::binary_segregator< Segregatable, RawAllocator >::binary_segregator ( segregatable s,
fallback_allocator_type fallback = fallback_allocator_type() )
inlineexplicit
Effects:
Creates it by giving the Segregatable and the RawAllocator.

Member Function Documentation

◆ allocate_array()

template<class Segregatable , class RawAllocator >
void * wpi::memory::binary_segregator< Segregatable, RawAllocator >::allocate_array ( std::size_t count,
std::size_t size,
std::size_t alignment )
inline

◆ allocate_node()

template<class Segregatable , class RawAllocator >
void * wpi::memory::binary_segregator< Segregatable, RawAllocator >::allocate_node ( std::size_t size,
std::size_t alignment )
inline
Effects:
Uses the Segregatable to decide which allocator to use. Then forwards to the chosen allocator.

◆ deallocate_array()

template<class Segregatable , class RawAllocator >
void wpi::memory::binary_segregator< Segregatable, RawAllocator >::deallocate_array ( void * array,
std::size_t count,
std::size_t size,
std::size_t alignment )
inlinenoexcept

◆ deallocate_node()

template<class Segregatable , class RawAllocator >
void wpi::memory::binary_segregator< Segregatable, RawAllocator >::deallocate_node ( void * ptr,
std::size_t size,
std::size_t alignment )
inlinenoexcept

◆ get_fallback_allocator() [1/2]

template<class Segregatable , class RawAllocator >
const fallback_allocator_type & wpi::memory::binary_segregator< Segregatable, RawAllocator >::get_fallback_allocator ( ) const
inlinenoexcept

◆ get_fallback_allocator() [2/2]

template<class Segregatable , class RawAllocator >
fallback_allocator_type & wpi::memory::binary_segregator< Segregatable, RawAllocator >::get_fallback_allocator ( )
inlinenoexcept
Returns:
A reference to the fallback allocator. It will be used if the Segregator doesn't want the alloction.

◆ get_segregatable_allocator() [1/2]

template<class Segregatable , class RawAllocator >
const segregatable_allocator_type & wpi::memory::binary_segregator< Segregatable, RawAllocator >::get_segregatable_allocator ( ) const
inlinenoexcept

◆ get_segregatable_allocator() [2/2]

template<class Segregatable , class RawAllocator >
segregatable_allocator_type & wpi::memory::binary_segregator< Segregatable, RawAllocator >::get_segregatable_allocator ( )
inlinenoexcept
Returns:
A reference to the segregatable allocator. This is the one primarily used.

◆ max_alignemnt()

template<class Segregatable , class RawAllocator >
std::size_t wpi::memory::binary_segregator< Segregatable, RawAllocator >::max_alignemnt ( ) const
inline

◆ max_array_size()

template<class Segregatable , class RawAllocator >
std::size_t wpi::memory::binary_segregator< Segregatable, RawAllocator >::max_array_size ( ) const
inline

◆ max_node_size()

template<class Segregatable , class RawAllocator >
std::size_t wpi::memory::binary_segregator< Segregatable, RawAllocator >::max_node_size ( ) const
inline
Returns:
The maximum value of the fallback.
Note
It assumes that the fallback will be used for larger allocations, and the Segregatable for smaller ones.

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