ATLAS Offline Software
Classes | Namespaces | Functions
ArenaSharedHeapSTLAllocator.h File Reference

STL-style allocator wrapper for ArenaHeapAllocator allowing the heap to be shared between containers. More...

#include "AthAllocators/ArenaHeapAllocator.h"
#include "AthAllocators/ArenaHeapSTLAllocator.h"
#include "AthAllocators/ArenaAllocatorRegistry.h"
#include "CxxUtils/concepts.h"
#include <string>
#include <vector>
#include "AthAllocators/ArenaSharedHeapSTLAllocator.icc"
Include dependency graph for ArenaSharedHeapSTLAllocator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SG::ArenaSharedHeapSTLAllocator< T >
 Forward declaration. More...
 
class  SG::ArenaSharedHeapSTLHeader
 Common header class for ArenaSharedHeapSTLAllocator. More...
 
class  SG::ArenaSharedHeapSTLAllocator< T >
 Forward declaration. More...
 
struct  SG::ArenaSharedHeapSTLAllocator< T >::rebind< U >
 Standard STL allocator rebinder. More...
 

Namespaces

 SG
 Forward declaration.
 

Functions

template<class T >
void SG::swap (ArenaSharedHeapSTLAllocator< T > &a, ArenaSharedHeapSTLAllocator< T > &b)
 
template<class T >
void SG::maybeUnprotect (ArenaSharedHeapSTLAllocator< T > &a)
 Hook for unprotecting an arena. More...
 

Detailed Description

STL-style allocator wrapper for ArenaHeapAllocator allowing the heap to be shared between containers.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Nov, 2011 This class defines a STL-style allocator for types T with the following special properties.

So, this allocator is suitable for an STL container which allocates lots of fixed-size objects, such as std::list, and further, you want to be able to have multiple list instances use the same pool.

Note that this allocator will not work for containers that make variable-sized allocations, such as vector and the hash table containers.

To use it, you should first explicitly create the allocator class, and then pass it to the constructors of the containers. The memory pool will be deleted when the original allocator instance is deleted. Example:

{
typedef std::list<int> list_t;
alloc_t allocator;
list_t list1 (allocator);
list_t list2 (allocator);
... Now list1 and list2 will both use the same memory pool.
}
... The memory pool is freed when the object `allocator' is deleted.

Implementation: Each allocator references a Header object, which is common to all allocators in the pool. When an allocator is copied, the header pointer is copied too. The Header object remembers the address of the allocator which originally created it, so that we can clean things up when that allocator goes away.

A Header contains a list of ArenaHeapAllocator objects, one per payload type. We use ArenaAllocatorRegistry to assign indices to the different allocator types.

Definition in file ArenaSharedHeapSTLAllocator.h.

pool
pool namespace
Definition: libname.h:15
python.TrigEgammaFastCaloHypoTool.same
def same(val, tool)
Definition: TrigEgammaFastCaloHypoTool.py:12
python.utils.AtlRunQueryMemUtil.memory
def memory(since=0.0)
Definition: AtlRunQueryMemUtil.py:30
update_CPContent.list1
list list1
Definition: update_CPContent.py:43
SG::ArenaSharedHeapSTLAllocator
Forward declaration.
Definition: ArenaSharedHeapSTLAllocator.h:75