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

STL-style allocator wrapper for ArenaPoolAllocator. More...

#include "AthAllocators/ArenaPoolAllocator.h"
#include "CxxUtils/concepts.h"
#include "CxxUtils/checker_macros.h"
#include <string>
#include <type_traits>
#include "AthAllocators/ArenaPoolSTLAllocator.icc"
Include dependency graph for ArenaPoolSTLAllocator.h:

Go to the source code of this file.

Classes

class  SG::ArenaPoolSTLAllocator_initParams< T >
 Initializer for pool allocator parameters. More...
 
class  SG::ArenaPoolSTLAllocator< T, VETO >
 STL-style allocator wrapper for ArenaPoolAllocator. More...
 
struct  SG::ArenaPoolSTLAllocator< T, VETO >::rebind< U >
 Standard STL allocator rebinder. More...
 
class  SG::ArenaPoolSTLAllocator< T *, VETO >
 STL-style allocator wrapper for ArenaPoolAllocator. More...
 
struct  SG::ArenaPoolSTLAllocator< T *, VETO >::rebind< U >
 Standard STL allocator rebinder. More...
 
class  SG::ArenaNonConstPoolSTLAllocator< T >
 Forward declaration. More...
 
class  SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >
 STL-style allocator wrapper for ArenaPoolAllocator. More...
 
struct  SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::rebind< U >
 Standard STL allocator rebinder. More...
 
class  SG::ArenaNonConstPoolSTLAllocator< T >
 Forward declaration. More...
 

Namespaces

 SG
 Forward declaration.
 

Functions

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

Detailed Description

STL-style allocator wrapper for ArenaPoolAllocator.

Author
scott snyder
Date
Jul 2008 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, where the usage pattern is to fill the container up, use it for a while, then delete the container. (The particular scenario that inspired this was the map for NavigationToken.)

Much of the complexity here is due to the fact that the allocator type that gets passed to the container is an allocator for the container's value_type, but that allocator is not actually used to allocate memory. Instead, an allocator for the internal node type is used. This makes it awkward if you want to have allocators that store state. We also need to support hash tables, which make two types of allocation. Nodes are fixed-size and are allocated individually, while the hash table is variable-sized and is of pointer type.

Further, to avoid creating a pool for the allocator for the container's value_type (when the container doesn't actually use that for allocation), this template has a second argument. This defaults to the first argument, but is passed through by rebind. If the first and second argument are the same, then we don't create a pool.

The effect of all this is that you can give an allocator type like ArenaPoolSTLAllocator<Mytype> to a STL container. Allocators for Mytype and Mytype* won't use a pool, but an allocator for node<Mytype> will use the pool.

Definition in file ArenaPoolSTLAllocator.h.