NSCL DDAS
12.1-001
Support for XIA DDAS at FRIB
|
Provides a class for memory management in reference-counted buffers. More...
#include <BufferArena.h>
Public Member Functions | |
virtual | ~BufferArena () |
Destructor. More... | |
ReferenceCountedBuffer * | allocate (size_t nBytes) |
Allocate and return a buffer. More... | |
void | free (ReferenceCountedBuffer *pBuffer) |
Returns a buffer to the pool. More... | |
Provides a class for memory management in reference-counted buffers.
Clients request storage of a specific size, and return it later. The storage is provided as a reference counted buffer.
Storage allocation strategy is relatively simplistic with the idea that statistically, all storage managed by this object will wind up eventually being resized to the biggest required block.
This is suitable for I/O buffers but very wasteful for ordinary storage management. The primary use case is for buffers for PXI readout.
|
virtual |
Destructor.
Destroy all buffers that are in the buffer pool. Note that there's no good way at present to detect destruction while there are still buffers outstanding.
ReferenceCountedBuffer * DDASReadout::BufferArena::allocate | ( | size_t | nBytes | ) |
Allocate and return a buffer.
nBytes | Number of bytes requested. |
If the pool is not empty the front element is gotten and resized. Otherwise, a new buffer element is created.
void DDASReadout::BufferArena::free | ( | ReferenceCountedBuffer * | pBuffer | ) |
Returns a buffer to the pool.
pBuffer | The buffer being returned. |