ATLAS Offline Software
Loading...
Searching...
No Matches
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
18
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
32namespace SG {
33
34
42{
43public:
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
101private:
102 typedef std::lock_guard<std::mutex> lock_t;
103
104
116
117
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
130 mutable std::mutex m_mutex;
131};
132
133
134} // namespace SG
135
136
138
139
140#endif // not ATLALLOCATORS_ARENABASE_H
141
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
A pointer type that holds a lock on an allocator object.
Common base class for arena allocator classes.
void reset()
Reset all contained allocators.
Definition ArenaBase.cxx:44
void report(std::ostream &os) const
Generate a report of the memory in use by this Arena.
Definition ArenaBase.cxx:76
ArenaAllocatorBase::Stats stats() const
Return statistics summed over all allocators in this Arena.
Definition ArenaBase.cxx:97
ArenaBase(const std::string &name="")
Constructor.
Definition ArenaBase.cxx:27
virtual ~ArenaBase()
Destructor.
Definition ArenaBase.cxx:36
std::lock_guard< std::mutex > lock_t
Definition ArenaBase.h:102
const std::string & name() const
Return this Arena's name.
void erase()
Erase all contained allocators.
Definition ArenaBase.cxx:60
ArenaBase & operator=(const ArenaBase &)=delete
std::mutex m_mutex
To guard access to m_allocs.
Definition ArenaBase.h:130
LockedAllocator allocator(size_t i)
Translate an integer index to an Allocator pointer.
std::string m_name
Our name.
Definition ArenaBase.h:127
ArenaBase(const ArenaBase &)=delete
ArenaAllocatorBase * makeAllocator(size_t i)
Make a new Allocator for index i.
std::vector< AllocEntry > m_allocs
Definition ArenaBase.h:124
A pointer type that holds a lock on an allocator object.
Forward declaration.
Statistics for an allocator.
Our allocator vector.
Definition ArenaBase.h:120
std::unique_ptr< std::mutex > m_mutex
Definition ArenaBase.h:122
std::unique_ptr< ArenaAllocatorBase > m_alloc
Definition ArenaBase.h:121