WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
slp::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 blocks_per_chunk)
 Constructs a default PoolResource.
 
 PoolResource (const PoolResource &)=delete
 Copy constructor.
 
PoolResourceoperator= (const PoolResource &)=delete
 Copy assignment operator.
 
 PoolResource (PoolResource &&)=default
 Move constructor.
 
PoolResourceoperator= (PoolResource &&)=default
 Move assignment operator.
 
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]

slp::PoolResource::PoolResource ( size_t blocks_per_chunk)
inlineexplicit

Constructs a default PoolResource.

Parameters
blocks_per_chunkNumber of blocks per chunk of memory.

◆ PoolResource() [2/3]

slp::PoolResource::PoolResource ( const PoolResource & )
delete

Copy constructor.

◆ PoolResource() [3/3]

slp::PoolResource::PoolResource ( PoolResource && )
default

Move constructor.

Member Function Documentation

◆ allocate()

void * slp::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).
Returns
A block of memory from the pool.

◆ blocks_in_use()

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

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

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

◆ deallocate()

void slp::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 slp::PoolResource::is_equal ( const PoolResource & other) const
inlinenoexcept

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

Parameters
otherThe other pool resource.
Returns
True if this pool resource has the same backing storage as another.

◆ operator=() [1/2]

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

Copy assignment operator.

Returns
This pool resource.

◆ operator=() [2/2]

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

Move assignment operator.

Returns
This pool resource.

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