WPILibC++ 2024.3.2
wpi::uv::SimpleBufferPool< DEPTH > Class Template Reference

A simple pool allocator for Buffers. More...

#include <wpinet/uv/Buffer.h>

Public Member Functions

 SimpleBufferPool (size_t size=4096)
 Constructor. More...
 
 ~SimpleBufferPool ()
 
 SimpleBufferPool (const SimpleBufferPool &other)=delete
 
SimpleBufferPooloperator= (const SimpleBufferPool &other)=delete
 
Buffer Allocate ()
 Allocate a buffer. More...
 
Buffer operator() ()
 Allocate a buffer. More...
 
void Release (std::span< Buffer > bufs)
 Release allocated buffers back into the pool. More...
 
void Clear ()
 Clear the pool, releasing all buffers. More...
 
size_t Remaining () const
 Get number of buffers left in the pool before a new buffer will be allocated from the heap. More...
 

Detailed Description

template<size_t DEPTH = 4>
class wpi::uv::SimpleBufferPool< DEPTH >

A simple pool allocator for Buffers.

Buffers are allocated individually but are reused rather than returned to the heap.

Template Parameters
DEPTHdepth of pool

Constructor & Destructor Documentation

◆ SimpleBufferPool() [1/2]

template<size_t DEPTH = 4>
wpi::uv::SimpleBufferPool< DEPTH >::SimpleBufferPool ( size_t  size = 4096)
inlineexplicit

Constructor.

Parameters
sizeSize of each buffer to allocate.

◆ ~SimpleBufferPool()

template<size_t DEPTH = 4>
wpi::uv::SimpleBufferPool< DEPTH >::~SimpleBufferPool ( )
inline

◆ SimpleBufferPool() [2/2]

template<size_t DEPTH = 4>
wpi::uv::SimpleBufferPool< DEPTH >::SimpleBufferPool ( const SimpleBufferPool< DEPTH > &  other)
delete

Member Function Documentation

◆ Allocate()

template<size_t DEPTH = 4>
Buffer wpi::uv::SimpleBufferPool< DEPTH >::Allocate ( )
inline

Allocate a buffer.

◆ Clear()

template<size_t DEPTH = 4>
void wpi::uv::SimpleBufferPool< DEPTH >::Clear ( )
inline

Clear the pool, releasing all buffers.

◆ operator()()

template<size_t DEPTH = 4>
Buffer wpi::uv::SimpleBufferPool< DEPTH >::operator() ( )
inline

Allocate a buffer.

◆ operator=()

template<size_t DEPTH = 4>
SimpleBufferPool & wpi::uv::SimpleBufferPool< DEPTH >::operator= ( const SimpleBufferPool< DEPTH > &  other)
delete

◆ Release()

template<size_t DEPTH = 4>
void wpi::uv::SimpleBufferPool< DEPTH >::Release ( std::span< Buffer bufs)
inline

Release allocated buffers back into the pool.

This is NOT safe to use with arbitrary buffers unless they were allocated with the same size as the buffer pool allocation size.

◆ Remaining()

template<size_t DEPTH = 4>
size_t wpi::uv::SimpleBufferPool< DEPTH >::Remaining ( ) const
inline

Get number of buffers left in the pool before a new buffer will be allocated from the heap.


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