lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds::Pool Class Referenceabstract

Abstract pool of numberofObjects equal buffers, each preceded by a PoolEntry, with allocation and free counters. More...

#include <Pool.hh>

Inherited by Pds::GenericPool.

Public Member Functions

virtual ~Pool ()
 Does nothing; empty virtual destructor.
 
 Pool (size_t sizeofObject, int numberofOfObjects)
 Set the object size and count and round each allocation (object plus PoolEntry header) up to a multiple of the PoolEntry size; the subclass calls populate() to create the buffers.
 
 Pool (size_t sizeofObject, int numberofOfObjects, unsigned alignBoundary)
 Like Pool(sizeofObject, numberofOfObjects), but rounds each allocation up to a multiple of alignBoundary.
 
void * alloc (size_t size)
 Take a buffer from the free list and count the allocation; returns nullptr if size exceeds the object size or none is available.
 
virtual void free (PoolEntry *)
 Return entry to the free list (enque()).
 
void clearCounters ()
 Zero the allocation and free counters.
 
size_t sizeofObject () const
 Return the object size given to the constructor.
 
int numberofObjects () const
 Return the number of buffers.
 
const uint64_t & numberofAllocs () const
 Return a reference to the allocation counter.
 
const uint64_t & numberofFrees () const
 Return a reference to the free counter.
 
int numberOfAllocatedObjects () const
 Return allocations minus frees.
 
int numberOfFreeObjects () const
 Return the number of buffers minus numberOfAllocatedObjects().
 

Static Public Member Functions

static void free (void *buffer)
 Return the user buffer buffer to the pool recorded in its PoolEntry header and count the free.
 
static int numberOfFreeObjects (void *buffer)
 Return numberOfFreeObjects() of the pool that owns buffer.
 

Protected Member Functions

size_t sizeofAllocate () const
 
virtual void * deque ()=0
 
virtual void enque (PoolEntry *)=0
 
virtual void * allocate (size_t size)=0
 
void populate ()
 

Detailed Description

Abstract pool of numberofObjects equal buffers, each preceded by a PoolEntry, with allocation and free counters.

Subclasses provide the storage and the free list.

Constructor & Destructor Documentation

◆ ~Pool()

Pds::Pool::~Pool ( )
inlinevirtual

Does nothing; empty virtual destructor.

◆ Pool() [1/2]

Pds::Pool::Pool ( size_t  sizeofObject,
int  numberofOfObjects 
)

Set the object size and count and round each allocation (object plus PoolEntry header) up to a multiple of the PoolEntry size; the subclass calls populate() to create the buffers.

◆ Pool() [2/2]

Pds::Pool::Pool ( size_t  sizeofObject,
int  numberofOfObjects,
unsigned  alignBoundary 
)

Like Pool(sizeofObject, numberofOfObjects), but rounds each allocation up to a multiple of alignBoundary.

Member Function Documentation

◆ alloc()

void * Pds::Pool::alloc ( size_t  size)
inline

Take a buffer from the free list and count the allocation; returns nullptr if size exceeds the object size or none is available.

◆ allocate()

virtual void * Pds::Pool::allocate ( size_t  size)
protectedpure virtual

Implemented in Pds::GenericPool.

◆ clearCounters()

void Pds::Pool::clearCounters ( )

Zero the allocation and free counters.

◆ deque()

virtual void * Pds::Pool::deque ( )
protectedpure virtual

Implemented in Pds::GenericPool, and Pds::GenericPoolW.

◆ enque()

virtual void Pds::Pool::enque ( PoolEntry *  )
protectedpure virtual

Implemented in Pds::GenericPool, and Pds::GenericPoolW.

◆ free() [1/2]

virtual void Pds::Pool::free ( PoolEntry *  )
virtual

Return entry to the free list (enque()).

◆ free() [2/2]

void Pds::Pool::free ( void *  buffer)
inlinestatic

Return the user buffer buffer to the pool recorded in its PoolEntry header and count the free.

◆ numberOfAllocatedObjects()

int Pds::Pool::numberOfAllocatedObjects ( ) const
inline

Return allocations minus frees.

◆ numberofAllocs()

const uint64_t & Pds::Pool::numberofAllocs ( ) const
inline

Return a reference to the allocation counter.

◆ numberOfFreeObjects() [1/2]

int Pds::Pool::numberOfFreeObjects ( ) const
inline

Return the number of buffers minus numberOfAllocatedObjects().

◆ numberOfFreeObjects() [2/2]

int Pds::Pool::numberOfFreeObjects ( void *  buffer)
inlinestatic

Return numberOfFreeObjects() of the pool that owns buffer.

◆ numberofFrees()

const uint64_t & Pds::Pool::numberofFrees ( ) const
inline

Return a reference to the free counter.

◆ numberofObjects()

int Pds::Pool::numberofObjects ( ) const
inline

Return the number of buffers.

◆ populate()

void Pds::Pool::populate ( )
protected

◆ sizeofAllocate()

size_t Pds::Pool::sizeofAllocate ( ) const
inlineprotected

◆ sizeofObject()

size_t Pds::Pool::sizeofObject ( ) const
inline

Return the object size given to the constructor.


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