NSCL DDAS  12.1-001
Support for XIA DDAS at FRIB
Public Member Functions | List of all members
DDASReadout::BufferArena Class Reference

Provides a class for memory management in reference-counted buffers. More...

#include <BufferArena.h>

Public Member Functions

virtual ~BufferArena ()
 Destructor. More...
 
ReferenceCountedBufferallocate (size_t nBytes)
 Allocate and return a buffer. More...
 
void free (ReferenceCountedBuffer *pBuffer)
 Returns a buffer to the pool. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~BufferArena()

DDASReadout::BufferArena::~BufferArena ( )
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.

Member Function Documentation

◆ allocate()

ReferenceCountedBuffer * DDASReadout::BufferArena::allocate ( size_t  nBytes)

Allocate and return a buffer.

Parameters
nBytesNumber of bytes requested.
Returns
Pointer to the buffer pool which is guaranteed to hold at least nBytes of storage.

If the pool is not empty the front element is gotten and resized. Otherwise, a new buffer element is created.

◆ free()

void DDASReadout::BufferArena::free ( ReferenceCountedBuffer pBuffer)

Returns a buffer to the pool.

Parameters
pBufferThe buffer being returned.
Note
This is only legal if the buffer is not referenced.

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