This is Unofficial EPICS BASE Doxygen Site
tsFreeList< T, N, MUTEX > Class Template Reference

#include "tsFreeList.h"

Public Member Functions

 tsFreeList ()
 
 ~tsFreeList ()
 
void * allocate (size_t size)
 
void release (void *p)
 
void release (void *p, size_t size)
 

Detailed Description

template<class T, unsigned N = 0x400, class MUTEX = epicsMutex>
class tsFreeList< T, N, MUTEX >

Definition at line 85 of file tsFreeList.h.

Constructor & Destructor Documentation

template<class T , unsigned N, class MUTEX >
tsFreeList< T, N, MUTEX >::tsFreeList ( )
inline

Definition at line 113 of file tsFreeList.h.

113  :
114  pFreeList ( 0 ), pChunkList ( 0 ) {}
template<class T , unsigned N, class MUTEX >
tsFreeList< T, N, MUTEX >::~tsFreeList ( )

Definition at line 117 of file tsFreeList.h.

118 {
119  while ( tsFreeListChunk < T, N > *pChunk = this->pChunkList ) {
120  this->pChunkList = this->pChunkList->pNext;
121  delete pChunk;
122  }
123 }

Member Function Documentation

template<class T , unsigned N, class MUTEX >
void * tsFreeList< T, N, MUTEX >::allocate ( size_t  size)

Definition at line 126 of file tsFreeList.h.

127 {
128  if ( size != sizeof ( T ) || N == 0u || tsFreeListDebugBypass ) {
129  void * p = ::operator new ( size );
130  tsFreeListMemSetNew ( p, size );
131  return p;
132  }
133 
134  epicsGuard < MUTEX > guard ( this->mutex );
135 
136  tsFreeListItem < T > * p = this->pFreeList;
137  if ( p ) {
138  this->pFreeList = p->pNext;
139  return static_cast < void * > ( p );
140  }
141  return this->allocateFromNewChunk ();
142 }
#define tsFreeListMemSetNew(P, SIZE)
Definition: tsFreeList.h:61
tsFreeListItem< T > * pNext
Definition: tsFreeList.h:103
#define tsFreeListDebugBypass
Definition: tsFreeList.h:60
template<class T , unsigned N, class MUTEX >
void tsFreeList< T, N, MUTEX >::release ( void *  p)

Definition at line 176 of file tsFreeList.h.

177 {
178  if ( N == 0u || tsFreeListDebugBypass ) {
179  tsFreeListMemSetDelete ( pCadaver, sizeof ( T ) );
180  ::operator delete ( pCadaver );
181  }
182  else if ( pCadaver ) {
183  epicsGuard < MUTEX > guard ( this->mutex );
185  static_cast < tsFreeListItem < T > * > ( pCadaver );
186  p->pNext = this->pFreeList;
187  this->pFreeList = p;
188  }
189 }
tsFreeListItem< T > * pNext
Definition: tsFreeList.h:103
#define tsFreeListDebugBypass
Definition: tsFreeList.h:60
#define tsFreeListMemSetDelete(P, SIZE)
Definition: tsFreeList.h:62
template<class T , unsigned N, class MUTEX >
void tsFreeList< T, N, MUTEX >::release ( void *  p,
size_t  size 
)

Definition at line 164 of file tsFreeList.h.

165 {
166  if ( size != sizeof ( T ) ) {
167  tsFreeListMemSetDelete ( pCadaver, size );
168  ::operator delete ( pCadaver );
169  }
170  else {
171  this->release ( pCadaver );
172  }
173 }
#define tsFreeListMemSetDelete(P, SIZE)
Definition: tsFreeList.h:62
void release(void *p)
Definition: tsFreeList.h:176

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