Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
BufferPool Class Reference

Class used to provide a pool of buffers that can have a dynamic size and be resized at any moment. More...

#include <bufferpool.hh>

Public Member Functions

 BufferPool (uint32_t initialNumber, uint32_t initialSize)
 Construct a BufferPool.
 
 ~BufferPool ()
 Destruct a BufferPool and free the memory.
 
BufferPoolNode * getBuffer ()
 Return a buffer from the pool. Note that the size of the buffer is random, so be sure to resize it to fit your needs.
 
void releaseBuffer (BufferPoolNode *buffer)
 Put back a buffer into the pool.
 

Detailed Description

Class used to provide a pool of buffers that can have a dynamic size and be resized at any moment.

Contrarily to MemoryPool, BufferPool provides a pool of buffers that can have a dynamic size and be resized at any moment. The drawback is that the BufferPool does not directly return a chunk of memory (as MemoryPool does) but a pointer to a BufferPoolNode that contains the memory chunk. The pointer to the BufferPoolNode must also be used to release memory.

Constructor & Destructor Documentation

◆ BufferPool()

BufferPool::BufferPool ( uint32_t  initialNumber,
uint32_t  initialSize 
)

Construct a BufferPool.

Parameters
initialNumberThe initial number of buffers in the pool
initialSizeThe initial size of the buffers in the pool

◆ ~BufferPool()

BufferPool::~BufferPool ( )

Destruct a BufferPool and free the memory.

Member Function Documentation

◆ getBuffer()

BufferPoolNode * BufferPool::getBuffer ( )

Return a buffer from the pool. Note that the size of the buffer is random, so be sure to resize it to fit your needs.

Returns
A pointer to a BufferPoolNode used to manage the buffer

◆ releaseBuffer()

void BufferPool::releaseBuffer ( BufferPoolNode *  buffer)

Put back a buffer into the pool.

Parameters
bufferA pointer to the BufferPoolNode used to manage the buffer

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