ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthAllocators
src
ArenaAllocatorBase.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
11
12
#include "
AthAllocators/ArenaAllocatorBase.h
"
13
#include <ostream>
14
#include <iomanip>
15
16
17
namespace
SG
{
18
19
23
ArenaAllocatorBase::Stats::Stat::Stat
()
24
:
inuse
(0),
25
free
(0),
26
total
(0)
27
{
28
}
29
30
34
void
ArenaAllocatorBase::Stats::Stat::clear
()
35
{
36
inuse
=
free
=
total
= 0;
37
}
38
39
44
ArenaAllocatorBase::Stats::Stat
&
45
ArenaAllocatorBase::Stats::Stat::operator+=
(
const
Stat
& other)
46
{
47
inuse
+= other.inuse;
48
free
+= other.free;
49
total
+= other.total;
50
return
*
this
;
51
}
52
53
54
/* (hide from doxygen)
55
* @brief Format a statistic structure.
56
* @param os The stream to which to write.
57
* @param stat The statistic structure to write.
58
*/
59
std::ostream&
operator<<
(std::ostream& os,
60
const
ArenaAllocatorBase::Stats::Stat
& stat)
61
{
62
std::print (os,
"{}"
, stat);
63
return
os;
64
}
65
66
67
//===========================================================================
68
69
73
void
ArenaAllocatorBase::Stats::clear
()
74
{
75
elts
.clear();
76
bytes
.clear();
77
blocks
.clear();
78
}
79
80
85
ArenaAllocatorBase::Stats
&
86
ArenaAllocatorBase::Stats::operator+=
(
const
Stats
& other)
87
{
88
elts
+= other.elts;
89
bytes
+= other.bytes;
90
blocks
+= other.blocks;
91
return
*
this
;
92
}
93
94
95
/* (hide from doxygen)
96
* @brief Format a complete statistics structure.
97
* @param os The stream to which to write.
98
* @param stats The statistics structure to write.
99
*/
100
std::ostream&
operator<<
(std::ostream& os,
101
const
ArenaAllocatorBase::Stats
&
stats
)
102
{
103
std::print (os,
"{}"
,
stats
);
104
return
os;
105
}
106
107
112
void
ArenaAllocatorBase::Stats::header
(std::ostream& os)
113
{
114
std::print (os,
"Elts InUse/Free/Total"
115
" Bytes InUse/Free/Total Blocks InUse/Free/Total"
);
116
}
117
118
119
//===========================================================================
120
121
126
void
ArenaAllocatorBase::report
(std::ostream& os)
const
127
{
128
std::println (os,
" {} {}"
,
stats
(),
name
());
129
}
130
131
132
}
// namespace SG
133
134
136
template
<
class
FmtContext>
137
typename
FmtContext::iterator
138
std::formatter<SG::ArenaAllocatorBase::Stats::Stat>::format (
const
SG::ArenaAllocatorBase::Stats::Stat
& stat, FmtContext& ctx)
const
139
{
140
return
std::format_to (ctx.out(),
"{:7}/{:7}/{:7}"
, stat.inuse, stat.free, stat.total);
141
}
142
143
145
template
<
class
FmtContext>
146
typename
FmtContext::iterator
147
std::formatter<SG::ArenaAllocatorBase::Stats>::format (
const
SG::ArenaAllocatorBase::Stats
&
stats
, FmtContext& ctx)
const
148
{
149
return
std::format_to (ctx.out(),
"{} {} {}"
,
stats
.
elts
,
stats
.
bytes
,
stats
.
blocks
);
150
}
ArenaAllocatorBase.h
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
SG::ArenaAllocatorBase::name
virtual const std::string & name() const =0
Return the name of this allocator.
SG::ArenaAllocatorBase::report
virtual void report(std::ostream &os) const
Generate a report on the memory usage of this allocator.
Definition
ArenaAllocatorBase.cxx:126
SG::ArenaAllocatorBase::stats
virtual Stats stats() const =0
Return the statistics block for this allocator.
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::operator<<
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
Definition
ArenaAllocatorBase.cxx:59
SG::ArenaAllocatorBase::Stats::Stat
A single statistic.
Definition
ArenaAllocatorBase.h:194
SG::ArenaAllocatorBase::Stats::Stat::operator+=
Stat & operator+=(const Stat &other)
Accumulate.
Definition
ArenaAllocatorBase.cxx:45
SG::ArenaAllocatorBase::Stats::Stat::clear
void clear()
Reset to zero.
Definition
ArenaAllocatorBase.cxx:34
SG::ArenaAllocatorBase::Stats::Stat::free
size_t free
Number of items currently not allocated by the application but cached by the allocator.
Definition
ArenaAllocatorBase.h:206
SG::ArenaAllocatorBase::Stats::Stat::Stat
Stat()
Default constructor.
Definition
ArenaAllocatorBase.cxx:23
SG::ArenaAllocatorBase::Stats::Stat::inuse
size_t inuse
Number of items currently allocated by the application.
Definition
ArenaAllocatorBase.h:203
SG::ArenaAllocatorBase::Stats::Stat::total
size_t total
Total number of items held by the allocator.
Definition
ArenaAllocatorBase.h:208
SG::ArenaAllocatorBase::Stats
Statistics for an allocator.
Definition
ArenaAllocatorBase.h:189
SG::ArenaAllocatorBase::Stats::blocks
Stat blocks
Counts of blocks.
Definition
ArenaAllocatorBase.h:218
SG::ArenaAllocatorBase::Stats::Stats
Stats()=default
SG::ArenaAllocatorBase::Stats::clear
void clear()
Reset to zero.
Definition
ArenaAllocatorBase.cxx:73
SG::ArenaAllocatorBase::Stats::elts
Stat elts
Counts of elements.
Definition
ArenaAllocatorBase.h:220
SG::ArenaAllocatorBase::Stats::header
static void header(std::ostream &os)
Print report header.
Definition
ArenaAllocatorBase.cxx:112
SG::ArenaAllocatorBase::Stats::operator+=
Stats & operator+=(const Stats &other)
Accumulate.
Definition
ArenaAllocatorBase.cxx:86
SG::ArenaAllocatorBase::Stats::bytes
Stat bytes
Counts of bytes.
Definition
ArenaAllocatorBase.h:222
Generated on
for ATLAS Offline Software by
1.17.0