TrackingTools
TrajectoryState
interface
ChurnAllocator.h
Go to the documentation of this file.
1
#ifndef Tracker_ChurnAllocator_H
2
#define Tracker_ChurnAllocator_H
3
#include <memory>
4
5
template
<
typename
T>
6
class
churn_allocator
:
public
std::allocator<T> {
7
public
:
8
using
Base
= std::allocator<T>;
9
using
pointer
=
typename
Base::pointer;
10
using
size_type
=
typename
Base::size_type
;
11
12
struct
Cache
{
13
pointer
cache
=
nullptr
;
14
bool
gard
=
false
;
15
};
16
17
static
Cache
&
cache
() {
18
static
thread_local
Cache
local
;
19
return
local
;
20
}
21
22
template
<
typename
_Tp1>
23
struct
rebind
{
24
typedef
churn_allocator<_Tp1>
other
;
25
};
26
27
pointer
allocate
(
size_type
n
,
const
void
*hint =
nullptr
) {
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
}
34
35
void
deallocate
(
pointer
p
,
size_type
n
) {
36
Cache
&
c
=
cache
();
37
if
(
p
==
c
.cache)
38
c
.gard =
true
;
39
else
40
std::allocator<T>::deallocate(
p
,
n
);
41
}
42
43
churn_allocator
() =
default
;
44
churn_allocator
(
churn_allocator
const
&) =
default
;
45
churn_allocator
(
churn_allocator
&&) =
default
;
46
47
template
<
class
U>
48
churn_allocator
(
const
churn_allocator<U>
&
a
) noexcept : std::allocator<T>(
a
) {}
49
};
50
51
#endif
churn_allocator
Definition:
ChurnAllocator.h:6
churn_allocator::rebind
Definition:
ChurnAllocator.h:23
churn_allocator::size_type
typename Base::size_type size_type
Definition:
ChurnAllocator.h:10
dqmiodumpmetadata.n
n
Definition:
dqmiodumpmetadata.py:28
churn_allocator::cache
static Cache & cache()
Definition:
ChurnAllocator.h:17
churn_allocator::churn_allocator
churn_allocator()=default
churn_allocator::Cache::cache
pointer cache
Definition:
ChurnAllocator.h:13
churn_allocator::rebind::other
churn_allocator< _Tp1 > other
Definition:
ChurnAllocator.h:24
churn_allocator::deallocate
void deallocate(pointer p, size_type n)
Definition:
ChurnAllocator.h:35
trigger::size_type
uint16_t size_type
Definition:
TriggerTypeDefs.h:18
a
double a
Definition:
hdecay.h:119
AlCaHLTBitMon_ParallelJobs.p
def p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
churn_allocator::Cache
Definition:
ChurnAllocator.h:12
churn_allocator::Base
std::allocator< T > Base
Definition:
ChurnAllocator.h:8
churn_allocator::churn_allocator
churn_allocator(const churn_allocator< U > &a) noexcept
Definition:
ChurnAllocator.h:48
churn_allocator::pointer
typename Base::pointer pointer
Definition:
ChurnAllocator.h:9
churn_allocator::Cache::gard
bool gard
Definition:
ChurnAllocator.h:14
DTRecHitClients_cfi.local
local
Definition:
DTRecHitClients_cfi.py:10
c
auto & c
Definition:
CAHitNtupletGeneratorKernelsImpl.h:56
churn_allocator::allocate
pointer allocate(size_type n, const void *hint=nullptr)
Definition:
ChurnAllocator.h:27
Generated for CMSSW Reference Manual by
1.8.16