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

◆ Base

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

Definition at line 8 of file ChurnAllocator.h.

◆ pointer

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

Definition at line 9 of file ChurnAllocator.h.

◆ size_type

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

Definition at line 10 of file ChurnAllocator.h.

Constructor & Destructor Documentation

◆ churn_allocator() [1/4]

template<typename T>
churn_allocator< T >::churn_allocator ( )
default

◆ churn_allocator() [2/4]

template<typename T>
churn_allocator< T >::churn_allocator ( churn_allocator< T > const &  )
default

◆ churn_allocator() [3/4]

template<typename T>
churn_allocator< T >::churn_allocator ( churn_allocator< T > &&  )
default

◆ churn_allocator() [4/4]

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

◆ allocate()

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(), and dqmiodumpmetadata::n.

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()

◆ cache()

template<typename T>
static Cache& churn_allocator< T >::cache ( )
inlinestatic

Definition at line 17 of file ChurnAllocator.h.

References DTRecHitClients_cfi::local.

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

17  {
18  static thread_local Cache local;
19  return local;
20  }

◆ deallocate()

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(), dqmiodumpmetadata::n, and AlCaHLTBitMon_ParallelJobs::p.

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()