ATLAS Offline Software
Loading...
Searching...
No Matches
ArenaHeader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: ArenaHeader.cxx 470529 2011-11-24 23:54:22Z ssnyder $
13
19#include <algorithm>
20#include <ostream>
21#include <sstream>
22#include <cassert>
23
24
25namespace SG {
26
27
29
30
35 // m_arena doesn't own the objects to which it points.
36 // Need to pass in a dummy deleter to prevent them from being deleted.
38{
39}
40
41
48{
49 // We don't own this.
50 m_arena.release();
51}
52
53
60{
61 ArenaBase* ret = m_arena.get();
62 m_arena.release();
63 m_arena.reset (arena);
64 return ret;
65}
66
67
73{
74 std::lock_guard<std::mutex> lock (m_mutex);
75 m_arenas.push_back (a);
76}
77
78
85{
86 if (slot < 0) return;
87 std::lock_guard<std::mutex> lock (m_mutex);
88 if (slot >= static_cast<int> (m_slots.size())) {
89 m_slots.resize (slot+1);
90 }
91 m_slots[slot] = a;
92}
93
94
102{
103 std::lock_guard<std::mutex> lock (m_mutex);
104 std::vector<ArenaBase*>::iterator it =
105 std::find (m_arenas.begin(), m_arenas.end(), a);
106 assert (it != m_arenas.end());
107 m_arenas.erase (it);
108}
109
110
115void ArenaHeader::report (std::ostream& os) const
116{
117 std::lock_guard<std::mutex> lock (m_mutex);
118 // All Allocators in the group.
119 for (ArenaBase* arena : m_arenas) {
120 os << "=== " << arena->name() << " ===" << std::endl;
121 arena->report (os);
122 }
123
124 // The default Arena.
125 os << "=== default ===" << std::endl;
126 m_defaultArena.report (os);
127}
128
129
137std::string ArenaHeader::reportStr() const
138{
139 std::ostringstream s;
140 report (s);
141 return s.str();
142}
143
144
154{
155 if (m_arena.get()) {
156 m_arena->reset();
157 }
158}
159
160
169
170
171} // 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 *)