CMS 3D CMS Logo

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=nullptr)
 
 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 8 of file ChurnAllocator.h.

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

Definition at line 9 of file ChurnAllocator.h.

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

Definition at line 10 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 48 of file ChurnAllocator.h.

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

Member Function Documentation

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

Definition at line 27 of file ChurnAllocator.h.

References HltBtagPostValidation_cff::c, churn_allocator< T >::Cache::cache, and churn_allocator< T >::Cache::gard.

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

Definition at line 17 of file ChurnAllocator.h.

References DTRecHitClients_cfi::local.

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

Definition at line 35 of file ChurnAllocator.h.

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

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