WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
sleipnir::PoolResource Class Reference

This class implements a pool memory resource. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/util/Pool.hpp>

Public Member Functions

 PoolResource (size_t blocksPerChunk)
 Constructs a default PoolResource.
 
 PoolResource (const PoolResource &)=delete
 
PoolResourceoperator= (const PoolResource &)=delete
 
 PoolResource (PoolResource &&)=default
 
PoolResourceoperator= (PoolResource &&)=default
 
void * allocate (size_t bytes, size_t alignment=alignof(std::max_align_t))
 Returns a block of memory from the pool.
 
void deallocate (void *p, size_t bytes, size_t alignment=alignof(std::max_align_t))
 Gives a block of memory back to the pool.
 
bool is_equal (const PoolResource &other) const noexcept
 Returns true if this pool resource has the same backing storage as another.
 
size_t blocks_in_use () const noexcept
 Returns the number of blocks from this pool resource that are in use.
 

Detailed Description

This class implements a pool memory resource.

The pool allocates chunks of memory and splits them into blocks managed by a free list. Allocations return pointers from the free list, and deallocations return pointers to the free list.

Constructor & Destructor Documentation

◆ PoolResource() [1/3]

sleipnir::PoolResource::PoolResource ( size_t blocksPerChunk)
inlineexplicit

Constructs a default PoolResource.

Parameters
blocksPerChunkNumber of blocks per chunk of memory.

◆ PoolResource() [2/3]

sleipnir::PoolResource::PoolResource ( const PoolResource & )
delete

◆ PoolResource() [3/3]

sleipnir::PoolResource::PoolResource ( PoolResource && )
default

Member Function Documentation

◆ allocate()

void * sleipnir::PoolResource::allocate ( size_t bytes,
size_t alignment = alignof(std::max_align_t) )
inlinenodiscard

Returns a block of memory from the pool.

Parameters
bytesNumber of bytes in the block.
alignmentAlignment of the block (unused).

◆ blocks_in_use()

size_t sleipnir::PoolResource::blocks_in_use ( ) const
inlinenoexcept

Returns the number of blocks from this pool resource that are in use.

◆ deallocate()

void sleipnir::PoolResource::deallocate ( void * p,
size_t bytes,
size_t alignment = alignof(std::max_align_t) )
inline

Gives a block of memory back to the pool.

Parameters
pA pointer to the block of memory.
bytesNumber of bytes in the block (unused).
alignmentAlignment of the block (unused).

◆ is_equal()

bool sleipnir::PoolResource::is_equal ( const PoolResource & other) const
inlinenoexcept

Returns true if this pool resource has the same backing storage as another.

◆ operator=() [1/2]

PoolResource & sleipnir::PoolResource::operator= ( const PoolResource & )
delete

◆ operator=() [2/2]

PoolResource & sleipnir::PoolResource::operator= ( PoolResource && )
default

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