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

Pool whose buffers are carved from one new[] block and kept on a Queue of PoolEntry (spin-locked); allocation returns nullptr when the queue is empty. More...

#include <GenericPool.hh>

Inherits Pds::Queue< T >, and Pds::Pool.

Inherited by Pds::GenericPoolW.

Public Member Functions

 GenericPool (size_t sizeofObject, int numberofObjects)
 Allocate a block for numberofObjects buffers of sizeofObject bytes plus headers and put all buffers on the free list.
 
 GenericPool (size_t sizeofObject, int numberofObjects, unsigned alignBoundary)
 Like GenericPool(sizeofObject, numberofObjects), with each user buffer aligned to alignBoundary (the block gets alignBoundary extra bytes).
 
 ~GenericPool ()
 Free the block.
 
void * buffer () const
 Return the start of the block.
 
size_t size () const
 Return the block size in bytes.
 
void dump () const
 Print the block size, address and fill offset, the object size and count, and the counters to stdout.
 
- Public Member Functions inherited from Pds::Pool
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().
 

Protected Member Functions

virtual void * deque ()
 
virtual void enque (PoolEntry *)
 
virtual void * allocate (size_t size)
 
- Protected Member Functions inherited from Pds::Pool
size_t sizeofAllocate () const
 
void populate ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Pds::Pool
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.
 

Detailed Description

Pool whose buffers are carved from one new[] block and kept on a Queue of PoolEntry (spin-locked); allocation returns nullptr when the queue is empty.

Constructor & Destructor Documentation

◆ GenericPool() [1/2]

Pds::GenericPool::GenericPool ( size_t  sizeofObject,
int  numberofObjects 
)
inline

Allocate a block for numberofObjects buffers of sizeofObject bytes plus headers and put all buffers on the free list.

◆ GenericPool() [2/2]

Pds::GenericPool::GenericPool ( size_t  sizeofObject,
int  numberofObjects,
unsigned  alignBoundary 
)
inline

Like GenericPool(sizeofObject, numberofObjects), with each user buffer aligned to alignBoundary (the block gets alignBoundary extra bytes).

◆ ~GenericPool()

Pds::GenericPool::~GenericPool ( )
inline

Free the block.

Member Function Documentation

◆ allocate()

void * Pds::GenericPool::allocate ( size_t  size)
inlineprotectedvirtual

Implements Pds::Pool.

◆ buffer()

void * Pds::GenericPool::buffer ( ) const
inline

Return the start of the block.

◆ deque()

void * Pds::GenericPool::deque ( )
inlineprotectedvirtual

Implements Pds::Pool.

Reimplemented in Pds::GenericPoolW.

◆ dump()

void Pds::GenericPool::dump ( ) const

Print the block size, address and fill offset, the object size and count, and the counters to stdout.

◆ enque()

void Pds::GenericPool::enque ( PoolEntry *  entry)
inlineprotectedvirtual

Implements Pds::Pool.

Reimplemented in Pds::GenericPoolW.

◆ size()

size_t Pds::GenericPool::size ( ) const
inline

Return the block size in bytes.


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