#include <Arena.h>
|
| class | Push |
| | Helper class for making Arena instances current in a stack-like manner. More...
|
|
| | Arena (const std::string &name, ArenaHeader *header=0) |
| | Constructor.
|
| | ~Arena () |
| | Destructor.
|
| ArenaHeader * | header () |
| | Return the ArenaHeader with which this Arena is associated.
|
| ArenaBase * | makeCurrent () |
| | Make this Arena the current one for its ArenaHeader.
|
| LockedAllocator | allocator (size_t i) |
| | Translate an integer index to an Allocator pointer.
|
| void | reset () |
| | Reset all contained allocators.
|
| void | erase () |
| | Erase all contained allocators.
|
| void | report (std::ostream &os) const |
| | Generate a report of the memory in use by this Arena.
|
| ArenaAllocatorBase::Stats | stats () const |
| | Return statistics summed over all allocators in this Arena.
|
| const std::string & | name () const |
| | Return this Arena's name.
|
|
| typedef std::lock_guard< std::mutex > | lock_t |
|
| ArenaAllocatorBase * | makeAllocator (size_t i) |
| | Make a new Allocator for index i.
|
Definition at line 236 of file Arena.h.
◆ lock_t
◆ Arena()
| Arena::Arena |
( |
const std::string & | name, |
|
|
ArenaHeader * | header = 0 ) |
Constructor.
- Parameters
-
| name | The name of this Arena; to use in reports. |
| header | The header with which this Arena is associated. If defaulted, the global default ArenaHeader will be used. |
Definition at line 26 of file Arena.cxx.
29{
32 }
34}
ArenaHeader * header()
Return the ArenaHeader with which this Arena is associated.
ArenaHeader * m_header
The ArenaHeader with which we're associated.
ArenaBase(const std::string &name="")
Constructor.
const std::string & name() const
Return this Arena's name.
◆ ~Arena()
◆ allocator()
| LockedAllocator SG::ArenaBase::allocator |
( |
size_t | i | ) |
|
|
inherited |
Translate an integer index to an Allocator pointer.
- Parameters
-
If the index isn't valid, an assertion will be tripped.
◆ erase()
| void SG::ArenaBase::erase |
( |
| ) |
|
|
inherited |
Erase all contained allocators.
All elements will be freed, and the memory returned to the system.
Definition at line 60 of file ArenaBase.cxx.
61{
64 if (alloc.m_alloc) {
65 lock_t alloc_lock (*alloc.m_mutex);
66 alloc.m_alloc->erase();
67 }
68 }
69}
std::lock_guard< std::mutex > lock_t
std::mutex m_mutex
To guard access to m_allocs.
std::vector< AllocEntry > m_allocs
l
Printing final latex table to .tex output file.
◆ header()
| ArenaHeader * Arena::header |
( |
| ) |
|
Return the ArenaHeader with which this Arena is associated.
Definition at line 49 of file Arena.cxx.
◆ makeAllocator()
| ArenaAllocatorBase * SG::ArenaBase::makeAllocator |
( |
size_t | i | ) |
|
|
privateinherited |
Make a new Allocator for index i.
- Parameters
-
| i | The index of the Allocator. |
The Allocator vector was empty for index i. Make an appropriate new Allocator, store it in the vector, and return it. Will trip an assertion if the index is not valid.
This should be called with m_mutex held.
Definition at line 130 of file ArenaBase.cxx.
131{
132
133
136 }
137
138
139 std::unique_ptr<ArenaAllocatorBase> alloc =
141
142
144 m_allocs[
i].m_mutex = std::make_unique<std::mutex>();
145
147}
std::unique_ptr< ArenaAllocatorBase > create(size_t i)
Create a new instance of an allocator.
static ArenaAllocatorRegistry * instance()
Return a pointer to the global ArenaAllocatorRegistry instance.
◆ makeCurrent()
Make this Arena the current one for its ArenaHeader.
- Returns
- The previously current Arena.
Definition at line 59 of file Arena.cxx.
◆ name()
| const std::string & SG::ArenaBase::name |
( |
| ) |
const |
|
inherited |
Return this Arena's name.
Definition at line 114 of file ArenaBase.cxx.
115{
117}
std::string m_name
Our name.
◆ report()
| void SG::ArenaBase::report |
( |
std::ostream & | os | ) |
const |
|
inherited |
Generate a report of the memory in use by this Arena.
- Parameters
-
| os | The stream to which to write the report. |
Definition at line 76 of file ArenaBase.cxx.
77{
81 if (alloc.m_alloc) {
82 if (first) {
86 }
87 lock_t alloc_lock (*alloc.m_mutex);
88 alloc.m_alloc->report (os);
89 }
90 }
91}
static void header(std::ostream &os)
Print report header.
◆ reset()
| void SG::ArenaBase::reset |
( |
| ) |
|
|
inherited |
Reset all contained allocators.
All elements will be freed.
Definition at line 44 of file ArenaBase.cxx.
45{
48 if (alloc.m_alloc) {
49 lock_t alloc_lock (*alloc.m_mutex);
50 alloc.m_alloc->reset();
51 }
52 }
53}
◆ stats()
| ArenaAllocatorBase::Stats SG::ArenaBase::stats |
( |
| ) |
const |
|
inherited |
Return statistics summed over all allocators in this Arena.
Definition at line 97 of file ArenaBase.cxx.
98{
99 ArenaAllocatorBase::Stats
stats;
102 if (alloc.m_alloc) {
103 lock_t alloc_lock (*alloc.m_mutex);
104 stats += alloc.m_alloc->stats();
105 }
106 }
108}
ArenaAllocatorBase::Stats stats() const
Return statistics summed over all allocators in this Arena.
◆ m_allocs
◆ m_header
| ArenaHeader* Arena::m_header |
|
private |
The ArenaHeader with which we're associated.
Definition at line 300 of file Arena.h.
◆ m_mutex
| std::mutex SG::ArenaBase::m_mutex |
|
mutableprivateinherited |
To guard access to m_allocs.
Definition at line 130 of file ArenaBase.h.
◆ m_name
| std::string SG::ArenaBase::m_name |
|
privateinherited |
The documentation for this class was generated from the following files: