WPILibC++  2020.3.2-60-g3011ebe
wpi::uv::SimpleBufferPool< DEPTH > Class Template Reference

A simple pool allocator for Buffers. More...

#include <Buffer.h>

Public Member Functions

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

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()

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


sizeSize of each buffer to allocate.

Member Function Documentation

◆ Release()

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

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.

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