nidas v1.2.3
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::SamplePool< SampleType > Class Template Reference

A pool of Samples. More...

#include <SamplePool.h>

Inheritance diagram for nidas::core::SamplePool< SampleType >:
Inheritance graph
[legend]

Public Member Functions

void deletePoolInstance ()
 Implementation from SamplePoolInterface which deletes the instance for this particular SamplePoolInterface subclass.
 
SampleType * getSample (unsigned int len)
 Get a sample of at least len elements from the pool.
 
void putSample (const SampleType *)
 Return a sample to the pool.
 
int getNSamplesAlloc () const
 
int getNSamplesOut () const
 
int getNSmallSamplesIn () const
 
int getNMediumSamplesIn () const
 
int getNLargeSamplesIn () const
 

Static Public Member Functions

static SamplePoolgetInstance ()
 Get a pointer to the singleton instance.
 
static void deleteInstance ()
 Singleton cleanup on program exit.
 

Public Attributes

int _nsmall
 
int _nmedium
 
int _nlarge
 
int _nsamplesOut
 
int _nsamplesAlloc
 

Private Member Functions

 SamplePool ()
 
 ~SamplePool ()
 
SampleType * getSample (SampleType **vec, int *veclen, unsigned int len)
 
void putSample (const SampleType *, SampleType ***vecp, int *veclen, int *nalloc)
 
 SamplePool (const SamplePool &)
 No copying.
 
SamplePooloperator= (const SamplePool &)
 No assignment.
 

Private Attributes

SampleType ** _smallSamples
 
SampleType ** _mediumSamples
 
SampleType ** _largeSamples
 
int _smallSize
 
int _mediumSize
 
int _largeSize
 
nidas::util::Mutex _poolLock
 

Static Private Attributes

static SamplePool_instance = 0
 
static nidas::util::Mutex _instanceLock = nidas::util::Mutex()
 
static const unsigned int SMALL_SAMPLE_MAXSIZE = 64
 maximum number of elements in a small sample
 
static const unsigned int MEDIUM_SAMPLE_MAXSIZE = 512
 maximum number of elements in a medium sized sample
 

Detailed Description

template<typename SampleType>
class nidas::core::SamplePool< SampleType >

A pool of Samples.

Actually three pools, containing samples segregated by size. A SamplePool can used as a singleton, and accessed from anywhere, via the getInstance() static member function.

Constructor & Destructor Documentation

◆ SamplePool() [1/2]

template<class SampleType >
nidas::core::SamplePool< SampleType >::SamplePool ( )
private

◆ ~SamplePool()

template<class SampleType >
nidas::core::SamplePool< SampleType >::~SamplePool ( )
private

◆ SamplePool() [2/2]

template<typename SampleType >
nidas::core::SamplePool< SampleType >::SamplePool ( const SamplePool< SampleType > & )
private

No copying.

Member Function Documentation

◆ deleteInstance()

template<class SampleType >
void nidas::core::SamplePool< SampleType >::deleteInstance ( )
static

Singleton cleanup on program exit.

References nidas::core::getSample().

Referenced by nidas::core::SamplePool< SampleType >::deletePoolInstance().

◆ deletePoolInstance()

template<typename SampleType >
void nidas::core::SamplePool< SampleType >::deletePoolInstance ( )
inlinevirtual

Implementation from SamplePoolInterface which deletes the instance for this particular SamplePoolInterface subclass.

Implements nidas::core::SamplePoolInterface.

References nidas::core::SamplePool< SampleType >::deleteInstance().

◆ getInstance()

template<class SampleType >
SamplePool< SampleType > * nidas::core::SamplePool< SampleType >::getInstance ( )
static

Get a pointer to the singleton instance.

References nidas::core::SamplePools::getInstance(), and nidas::core::getSample().

◆ getNLargeSamplesIn()

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::getNLargeSamplesIn ( ) const
inlinevirtual

◆ getNMediumSamplesIn()

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::getNMediumSamplesIn ( ) const
inlinevirtual

◆ getNSamplesAlloc()

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::getNSamplesAlloc ( ) const
inlinevirtual

◆ getNSamplesOut()

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::getNSamplesOut ( ) const
inlinevirtual

◆ getNSmallSamplesIn()

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::getNSmallSamplesIn ( ) const
inlinevirtual

◆ getSample() [1/2]

template<class SampleType >
SampleType * nidas::core::SamplePool< SampleType >::getSample ( SampleType ** vec,
int * veclen,
unsigned int len )
private

◆ getSample() [2/2]

template<class SampleType >
SampleType * nidas::core::SamplePool< SampleType >::getSample ( unsigned int len)

Get a sample of at least len elements from the pool.

References nidas::core::getSample(), and len.

Referenced by nidas::core::SamplePool< SampleType >::SamplePool().

◆ operator=()

No assignment.

◆ putSample() [1/2]

template<class SampleType >
void nidas::core::SamplePool< SampleType >::putSample ( const SampleType * sample)

Return a sample to the pool.

References DLOG, nidas::core::getSample(), and len.

◆ putSample() [2/2]

template<class SampleType >
void nidas::core::SamplePool< SampleType >::putSample ( const SampleType * sample,
SampleType *** vecp,
int * veclen,
int * nalloc )
private

References DLOG, and nidas::core::getSample().

Member Data Documentation

◆ _instance

template<class SampleType >
SamplePool< SampleType > * nidas::core::SamplePool< SampleType >::_instance = 0
staticprivate

◆ _instanceLock

template<class SampleType >
nidas::util::Mutex nidas::core::SamplePool< SampleType >::_instanceLock = nidas::util::Mutex()
staticprivate

◆ _largeSamples

template<typename SampleType >
SampleType** nidas::core::SamplePool< SampleType >::_largeSamples
private

◆ _largeSize

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::_largeSize
private

◆ _mediumSamples

template<typename SampleType >
SampleType** nidas::core::SamplePool< SampleType >::_mediumSamples
private

◆ _mediumSize

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::_mediumSize
private

◆ _nlarge

◆ _nmedium

◆ _nsamplesAlloc

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::_nsamplesAlloc

◆ _nsamplesOut

◆ _nsmall

◆ _poolLock

◆ _smallSamples

template<typename SampleType >
SampleType** nidas::core::SamplePool< SampleType >::_smallSamples
private

◆ _smallSize

template<typename SampleType >
int nidas::core::SamplePool< SampleType >::_smallSize
private

◆ MEDIUM_SAMPLE_MAXSIZE

template<typename SampleType >
const unsigned int nidas::core::SamplePool< SampleType >::MEDIUM_SAMPLE_MAXSIZE = 512
staticprivate

maximum number of elements in a medium sized sample

Referenced by nidas::core::SamplePool< SampleType >::SamplePool().

◆ SMALL_SAMPLE_MAXSIZE

template<typename SampleType >
const unsigned int nidas::core::SamplePool< SampleType >::SMALL_SAMPLE_MAXSIZE = 64
staticprivate

maximum number of elements in a small sample

Referenced by nidas::core::SamplePool< SampleType >::SamplePool().


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