test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions
churn_allocator< T > Class Template Reference

#include <ChurnAllocator.h>

Inheritance diagram for churn_allocator< T >:

Classes

struct  Cache
 
struct  rebind
 

Public Types

using Base = std::allocator< T >
 
using pointer = typename Base::pointer
 
using size_type = typename Base::size_type
 

Public Member Functions

pointer allocate (size_type n, const void *hint=0)
 
 churn_allocator ()=default
 
 churn_allocator (churn_allocator const &)=default
 
 churn_allocator (churn_allocator &&)=default
 
template<class U >
 churn_allocator (const churn_allocator< U > &a) noexcept
 
void deallocate (pointer p, size_type n)
 

Static Public Member Functions

static Cachecache ()
 

Detailed Description

template<typename T>
class churn_allocator< T >

Definition at line 6 of file ChurnAllocator.h.

Member Typedef Documentation

template<typename T>
using churn_allocator< T >::Base = std::allocator<T>

Definition at line 9 of file ChurnAllocator.h.

template<typename T>
using churn_allocator< T >::pointer = typename Base::pointer

Definition at line 10 of file ChurnAllocator.h.

template<typename T>
using churn_allocator< T >::size_type = typename Base::size_type

Definition at line 11 of file ChurnAllocator.h.

Constructor & Destructor Documentation

template<typename T>
churn_allocator< T >::churn_allocator ( )
default
template<typename T>
churn_allocator< T >::churn_allocator ( churn_allocator< T > const &  )
default
template<typename T>
churn_allocator< T >::churn_allocator ( churn_allocator< T > &&  )
default
template<typename T>
template<class U >
churn_allocator< T >::churn_allocator ( const churn_allocator< U > &  a)
inlinenoexcept

Definition at line 50 of file ChurnAllocator.h.

50 : std::allocator<T>(a) { }
double a
Definition: hdecay.h:121

Member Function Documentation

template<typename T>
pointer churn_allocator< T >::allocate ( size_type  n,
const void *  hint = 0 
)
inline

Definition at line 30 of file ChurnAllocator.h.

References EnergyCorrector::c, churn_allocator< T >::Cache::cache, churn_allocator< T >::cache(), and churn_allocator< T >::Cache::gard.

31  {
32  Cache & c = cache();
33  if (!c.gard)
34  c.cache = std::allocator<T>::allocate(n, hint);
35  c.gard=false; return c.cache;
36  }
static Cache & cache()
template<typename T>
static Cache& churn_allocator< T >::cache ( )
inlinestatic

Definition at line 18 of file ChurnAllocator.h.

Referenced by churn_allocator< T >::allocate(), and churn_allocator< T >::deallocate().

18  {
19  static thread_local Cache local;
20  return local;
21  }
template<typename T>
void churn_allocator< T >::deallocate ( pointer  p,
size_type  n 
)
inline

Definition at line 38 of file ChurnAllocator.h.

References EnergyCorrector::c, churn_allocator< T >::Cache::cache, churn_allocator< T >::cache(), and churn_allocator< T >::Cache::gard.

39  {
40  Cache & c = cache();
41  if (p==c.cache) c.gard=true;
42  else std::allocator<T>::deallocate(p, n);
43  }
static Cache & cache()