ATLAS Offline Software
Loading...
Searching...
No Matches
ArenaHeader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
11
17#include <algorithm>
18#include <ostream>
19#include <sstream>
20#include <print>
21#include <cassert>
22
23
24namespace SG {
25
26
28
29
34 // m_arena doesn't own the objects to which it points.
35 // Need to pass in a dummy deleter to prevent them from being deleted.
37{
38}
39
40
47{
48 // We don't own this.
49 m_arena.release();
50}
51
52
59{
60 ArenaBase* ret = m_arena.get();
61 m_arena.release();
62 m_arena.reset (arena);
63 return ret;
64}
65
66
72{
73 std::lock_guard<std::mutex> lock (m_mutex);
74 m_arenas.push_back (a);
75}
76
77
84{
85 if (slot < 0) return;
86 std::lock_guard<std::mutex> lock (m_mutex);
87 if (slot >= static_cast<int> (m_slots.size())) {
88 m_slots.resize (slot+1);
89 }
90 m_slots[slot] = a;
91}
92
93
101{
102 std::lock_guard<std::mutex> lock (m_mutex);
103 std::vector<ArenaBase*>::iterator it =
104 std::find (m_arenas.begin(), m_arenas.end(), a);
105 assert (it != m_arenas.end());
106 m_arenas.erase (it);
107}
108
109
114void ArenaHeader::report (std::ostream& os) const
115{
116 std::lock_guard<std::mutex> lock (m_mutex);
117 // All Allocators in the group.
118 for (ArenaBase* arena : m_arenas) {
119 std::println (os, "=== {} ===", arena->name());
120 arena->report (os);
121 }
122
123 // The default Arena.
124 std::println (os, "=== default ===");
125 m_defaultArena.report (os);
126}
127
128
136std::string ArenaHeader::reportStr() const
137{
138 std::ostringstream s;
139 report (s);
140 return s.str();
141}
142
143
153{
154 if (m_arena.get()) {
155 m_arena->reset();
156 }
157}
158
159
168
169
170} // namespace SG
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
Registry of allocator factories. See Arena.h for an overview of the arena-based memory allocators.
Part of Arena dealing with the list of allocators. Broken out from Arena to avoid a dependency loop w...
Proxy for a group of Arenas. See Arena.h for an overview of the arena-based memory allocators.
static Double_t a
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Part of Arena dealing with the list of allocators.
Definition ArenaBase.h:42
ArenaBase * setArena(ArenaBase *arena)
Set the current Arena for the current thread.
void addArena(ArenaBase *a)
Add a new Arena to the group.
std::string reportStr() const
Generate a report of all Arenas in the group, and return the result as a string.
void delArena(ArenaBase *a)
Remove an Arena from the group.
std::vector< ArenaBase * > m_arenas
List of all Arenas in our group.
void reset()
Call reset on all Allocators in the current Arena.
boost::thread_specific_ptr< ArenaBase > m_arena
Current Arena.
void report(std::ostream &os) const
Generate a report of all Arenas in the group.
~ArenaHeader()
Destructor.
std::vector< ArenaBase * > m_slots
Arenas indexed by event slot.
ArenaHeader()
Constructor.
static ArenaHeader * defaultHeader()
Return the global default Header instance.
ArenaBase m_defaultArena
The default Arena.
void setArenaForSlot(int slot, ArenaBase *a)
Record the arena associated with an event slot.
std::mutex m_mutex
Mutex to protect access to m_defaultArena, m_arenas, and m_slots.
std::string head(std::string s, const std::string &pattern)
head of a string
Forward declaration.
void null_arena_deleter(ArenaBase *)
virtual void lock() override
Lock the container.