ATLAS Offline Software
|
Proxy for a group of Arenas. More...
#include <ArenaHeader.h>
Public Member Functions | |
ArenaHeader () | |
Constructor. More... | |
~ArenaHeader () | |
Destructor. More... | |
LockedAllocator | allocator (size_t i) |
Translate an integer index to an Allocator pointer. More... | |
LockedAllocator | allocator (const EventContext &ctx, size_t i) |
Translate an integer index to an Allocator pointer. More... | |
ArenaBase * | setArena (ArenaBase *arena) |
Set the current Arena for the current thread. More... | |
void | addArena (ArenaBase *a) |
Add a new Arena to the group. More... | |
void | setArenaForSlot (int slot, ArenaBase *a) |
Record the arena associated with an event slot. More... | |
void | delArena (ArenaBase *a) |
Remove an Arena from the group. More... | |
void | report (std::ostream &os) const |
Generate a report of all Arenas in the group. More... | |
std::string | reportStr () const |
Generate a report of all Arenas in the group, and return the result as a string. More... | |
void | reset () |
Call reset on all Allocators in the current Arena. More... | |
Static Public Member Functions | |
static ArenaHeader * | defaultHeader () |
Return the global default Header instance. More... | |
Private Attributes | |
boost::thread_specific_ptr< ArenaBase > | m_arena |
Current Arena. More... | |
ArenaBase | m_defaultArena |
The default Arena. More... | |
std::vector< ArenaBase * > | m_arenas |
List of all Arenas in our group. More... | |
std::vector< ArenaBase * > | m_slots |
Arenas indexed by event slot. More... | |
std::mutex | m_mutex |
Mutex to protect access to m_defaultArena, m_arenas, and m_slots. More... | |
Proxy for a group of Arenas.
See Arena.h for an overview of the arena-based memory allocators.
A Header collects a group of Arenas. One of these is the current Arena, in which memory operations will take place. We can also generate a report of memory usage from all the Arenas in the group.
We keep a thread-specific pointer to the current Arena, which is used to handle the mapping from indices to Allocator instances.
Definition at line 53 of file ArenaHeader.h.
SG::ArenaHeader::ArenaHeader | ( | ) |
Constructor.
Definition at line 34 of file ArenaHeader.cxx.
SG::ArenaHeader::~ArenaHeader | ( | ) |
Destructor.
This will clean up any memory allocated in the default Arena.
Definition at line 47 of file ArenaHeader.cxx.
void SG::ArenaHeader::addArena | ( | ArenaBase * | a | ) |
LockedAllocator SG::ArenaHeader::allocator | ( | const EventContext & | ctx, |
size_t | i | ||
) |
Translate an integer index to an Allocator pointer.
ctx | Use the Arena associated with this event context. |
i | The index to look up. |
If the index isn't valid, an assertion will be tripped.
LockedAllocator SG::ArenaHeader::allocator | ( | size_t | i | ) |
Translate an integer index to an Allocator pointer.
i | The index to look up. |
The default Arena will be used.
If the index isn't valid, an assertion will be tripped.
|
static |
Return the global default Header instance.
Definition at line 164 of file ArenaHeader.cxx.
void SG::ArenaHeader::delArena | ( | ArenaBase * | a | ) |
Remove an Arena from the group.
a | The Arena to remove. |
Will trip an assertion if the Arena is not in the group.
Definition at line 101 of file ArenaHeader.cxx.
void SG::ArenaHeader::report | ( | std::ostream & | os | ) | const |
Generate a report of all Arenas in the group.
os | Stream to which to send a report. |
Definition at line 115 of file ArenaHeader.cxx.
std::string SG::ArenaHeader::reportStr | ( | ) | const |
Generate a report of all Arenas in the group, and return the result as a string.
We have this in addition to report()
in order to make it easier to call from scripting languages.
Definition at line 137 of file ArenaHeader.cxx.
void SG::ArenaHeader::reset | ( | ) |
Call reset
on all Allocators in the current Arena.
All elements allocated are returned to the free state. clear
should be called on them if it was provided. The elements may continue to be cached internally, without returning to the system.
Definition at line 153 of file ArenaHeader.cxx.
void SG::ArenaHeader::setArenaForSlot | ( | int | slot, |
ArenaBase * | a | ||
) |
Record the arena associated with an event slot.
slot | The slot number. |
a | The Arena instance. |
Definition at line 84 of file ArenaHeader.cxx.
|
private |
Current Arena.
Definition at line 159 of file ArenaHeader.h.
|
private |
List of all Arenas in our group.
Definition at line 165 of file ArenaHeader.h.
|
private |
The default Arena.
Definition at line 162 of file ArenaHeader.h.
|
mutableprivate |
Mutex to protect access to m_defaultArena, m_arenas, and m_slots.
Definition at line 171 of file ArenaHeader.h.
|
private |
Arenas indexed by event slot.
Definition at line 168 of file ArenaHeader.h.