ATLAS Offline Software
ArenaBase.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id: ArenaBase.h 470529 2011-11-24 23:54:22Z ssnyder $
8 
19 #ifndef ATLALLOCATORS_ARENABASE_H
20 #define ATLALLOCATORS_ARENABASE_H
21 
22 
25 #include <iosfwd>
26 #include <string>
27 #include <vector>
28 #include <memory>
29 #include <mutex>
30 
31 
32 namespace SG {
33 
34 
41 class ArenaBase
42 {
43 public:
48  ArenaBase (const std::string& name = "");
49 
50 
52  virtual ~ArenaBase();
53 
54 
55  ArenaBase (const ArenaBase&) = delete;
56  ArenaBase& operator= (const ArenaBase&) = delete;
57 
58 
59 
67 
68 
72  void reset();
73 
74 
79  void erase();
80 
81 
86  void report (std::ostream& os) const;
87 
88 
93 
94 
98  const std::string& name() const;
99 
100 
101 private:
102  typedef std::lock_guard<std::mutex> lock_t;
103 
104 
116 
117 
119  struct AllocEntry
120  {
121  std::unique_ptr<ArenaAllocatorBase> m_alloc;
122  std::unique_ptr<std::mutex> m_mutex;
123  };
124  std::vector<AllocEntry> m_allocs;
125 
127  std::string m_name;
128 
131 };
132 
133 
134 } // namespace SG
135 
136 
138 
139 
140 #endif // not ATLALLOCATORS_ARENABASE_H
141 
SG::ArenaBase::~ArenaBase
virtual ~ArenaBase()
Destructor.
Definition: ArenaBase.cxx:36
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaBase::m_allocs
std::vector< AllocEntry > m_allocs
Definition: ArenaBase.h:124
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
SG::ArenaBase::makeAllocator
ArenaAllocatorBase * makeAllocator(size_t i)
Make a new Allocator for index i.
Definition: ArenaBase.cxx:130
SG::ArenaBase::ArenaBase
ArenaBase(const std::string &name="")
Constructor.
Definition: ArenaBase.cxx:27
SG::ArenaBase::report
void report(std::ostream &os) const
Generate a report of the memory in use by this Arena.
Definition: ArenaBase.cxx:76
LockedAllocator.h
A pointer type that holds a lock on an allocator object.
SG::ArenaAllocatorBase::Stats
Statistics for an allocator.
Definition: ArenaAllocatorBase.h:188
lumiFormat.i
int i
Definition: lumiFormat.py:92
SG::ArenaBase::m_name
std::string m_name
Our name.
Definition: ArenaBase.h:127
SG::ArenaBase::reset
void reset()
Reset all contained allocators.
Definition: ArenaBase.cxx:44
ArenaAllocatorBase.h
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
SG::ArenaAllocatorBase
Common base class for arena allocator classes.
Definition: ArenaAllocatorBase.h:134
SG::LockedAllocator
A pointer type that holds a lock on an allocator object.
Definition: LockedAllocator.h:40
SG::ArenaBase
Part of Arena dealing with the list of allocators.
Definition: ArenaBase.h:42
SG::ArenaBase::erase
void erase()
Erase all contained allocators.
Definition: ArenaBase.cxx:60
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ArenaBase::ArenaBase
ArenaBase(const ArenaBase &)=delete
SG::ArenaBase::allocator
LockedAllocator allocator(size_t i)
Translate an integer index to an Allocator pointer.
SG::ArenaBase::AllocEntry::m_alloc
std::unique_ptr< ArenaAllocatorBase > m_alloc
Definition: ArenaBase.h:121
SG::ArenaBase::operator=
ArenaBase & operator=(const ArenaBase &)=delete
ArenaBase.icc
SG::ArenaBase::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ArenaBase.h:102
SG::ArenaBase::AllocEntry::m_mutex
std::unique_ptr< std::mutex > m_mutex
Definition: ArenaBase.h:122
SG::ArenaBase::stats
ArenaAllocatorBase::Stats stats() const
Return statistics summed over all allocators in this Arena.
Definition: ArenaBase.cxx:97
SG::ArenaBase::m_mutex
std::mutex m_mutex
To guard access to m_allocs.
Definition: ArenaBase.h:130
SG::ArenaBase::AllocEntry
Our allocator vector.
Definition: ArenaBase.h:120
SG::ArenaBase::name
const std::string & name() const
Return this Arena's name.
Definition: ArenaBase.cxx:114