ATLAS Offline Software
Loading...
Searching...
No Matches
ArenaAllocatorBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: ArenaAllocatorBase.cxx 470529 2011-11-24 23:54:22Z ssnyder $
13
15#include <ostream>
16#include <iomanip>
17
18
19namespace SG {
20
21
26 : inuse (0),
27 free (0),
28 total (0)
29{
30}
31
32
40
41
48{
49 inuse += other.inuse;
50 free += other.free;
51 total += other.total;
52 return *this;
53}
54
55
56/* (hide from doxygen)
57 * @brief Format a statistic structure.
58 * @param os The stream to which to write.
59 * @param stat The statistic structure to write.
60 */
61std::ostream& operator<< (std::ostream& os,
63{
64 os << std::setw(7) << stat.inuse << "/"
65 << std::setw(7) << stat.free << "/"
66 << std::setw(7) << stat.total;
67 return os;
68}
69
70
71//===========================================================================
72
73
78{
79 elts.clear();
80 bytes.clear();
81 blocks.clear();
82}
83
84
91{
92 elts += other.elts;
93 bytes += other.bytes;
94 blocks += other.blocks;
95 return *this;
96}
97
98
99/* (hide from doxygen)
100 * @brief Format a complete statistics structure.
101 * @param os The stream to which to write.
102 * @param stats The statistics structure to write.
103 */
104std::ostream& operator<< (std::ostream& os,
106{
107 os << stats.elts << " " << stats.bytes << " " << stats.blocks;
108 return os;
109}
110
111
117{
118 os << "Elts InUse/Free/Total"
119 << " Bytes InUse/Free/Total Blocks InUse/Free/Total";
120}
121
122
123//===========================================================================
124
125
130void ArenaAllocatorBase::report (std::ostream& os) const
131{
132 os << " " << stats() << " " << name() << std::endl;
133}
134
135
136} // namespace SG
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
virtual const std::string & name() const =0
Return the name of this allocator.
virtual void report(std::ostream &os) const
Generate a report on the memory usage of this allocator.
virtual Stats stats() const =0
Return the statistics block for this allocator.
Forward declaration.
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
Stat & operator+=(const Stat &other)
Accumulate.
size_t free
Number of items currently not allocated by the application but cached by the allocator.
size_t inuse
Number of items currently allocated by the application.
size_t total
Total number of items held by the allocator.
Statistics for an allocator.
static void header(std::ostream &os)
Print report header.
Stats & operator+=(const Stats &other)
Accumulate.