ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
SG::ArenaPoolSTLAllocator< T, VETO > Class Template Reference

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

#include <ArenaPoolSTLAllocator.h>

Collaboration diagram for SG::ArenaPoolSTLAllocator< T, VETO >:

Classes

struct  rebind
 Standard STL allocator rebinder. More...
 

Public Types

typedef T * pointer
 Standard STL allocator typedefs. More...
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T value_type
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef std::false_type propagate_on_container_copy_assignment
 When we assign to a container, the target should retain its allocator. More...
 
typedef std::true_type propagate_on_container_move_assignment
 Move allocators on move/swap. More...
 
typedef std::true_type propagate_on_container_swap
 

Public Member Functions

 ArenaPoolSTLAllocator (size_t nblock=1000, const std::string &name="")
 Default constructor. More...
 
 ArenaPoolSTLAllocator (const ArenaPoolSTLAllocator &a)
 Copy constructor. More...
 
template<class U , class V >
 ArenaPoolSTLAllocator (const ArenaPoolSTLAllocator< U, V > &a)
 Constructor from another ArenaPoolSTLAllocator. More...
 
 ArenaPoolSTLAllocator (ArenaPoolSTLAllocator &&a)
 Move constructor. More...
 
ArenaPoolSTLAllocatoroperator= (ArenaPoolSTLAllocator &&a)
 Move assignment. More...
 
void swap (ArenaPoolSTLAllocator &a)
 Swap. More...
 
ArenaPoolSTLAllocator select_on_container_copy_construction () const
 Return allocator to use for a copy-constructed container. More...
 
bool operator== (const ArenaPoolSTLAllocator &other) const
 Equality test. More...
 
bool operator!= (const ArenaPoolSTLAllocator &other) const
 Inequality test. More...
 
pointer address (reference x) const
 Convert a reference to an address. More...
 
 ATH_MEMBER_REQUIRES (!(std::is_same_v< reference, const_reference >), const_pointer) address(const_reference x) const
 
pointer allocate (size_type n, const void *hint=0)
 Allocate new objects. More...
 
void deallocate (pointer, size_type n)
 Deallocate objects. More...
 
size_type max_size () const throw ()
 Return the maximum number of objects we can allocate at once. More...
 
template<class... Args>
void construct (pointer p, Args &&... args)
 Call the T constructor. More...
 
void destroy (pointer p)
 Call the T destructor. More...
 
size_t nblock () const
 Return the hinted number of objects allocated per block. More...
 
const std::string & name () const
 Return the name of this allocator. More...
 
void reset ()
 Free all allocated elements. More...
 
void erase ()
 Free all allocated elements and release memory back to the system. More...
 
void reserve (size_t size)
 Set the total number of elements cached by the allocator. More...
 
ArenaAllocatorBase::Stats stats () const
 Return the statistics block for this allocator. More...
 
const ArenaBlockAllocatorBasepoolptr () const
 Return a pointer to the underlying allocator (may be 0). More...
 
void protect ()
 Write-protect the memory managed by this allocator. More...
 
void unprotect ()
 Write-enable the memory managed by this allocator. More...
 

Private Attributes

ArenaPoolAllocator m_pool
 The underlying allocator. More...
 

Detailed Description

template<class T, class VETO = T>
class SG::ArenaPoolSTLAllocator< T, VETO >

STL-style allocator wrapper for ArenaPoolAllocator.

This is the generic specialization, which uses the pool allocator.

See the file-level comments for details.

Definition at line 105 of file ArenaPoolSTLAllocator.h.

Member Typedef Documentation

◆ const_pointer

template<class T , class VETO = T>
typedef const T* SG::ArenaPoolSTLAllocator< T, VETO >::const_pointer

Definition at line 110 of file ArenaPoolSTLAllocator.h.

◆ const_reference

template<class T , class VETO = T>
typedef const T& SG::ArenaPoolSTLAllocator< T, VETO >::const_reference

Definition at line 112 of file ArenaPoolSTLAllocator.h.

◆ difference_type

template<class T , class VETO = T>
typedef ptrdiff_t SG::ArenaPoolSTLAllocator< T, VETO >::difference_type

Definition at line 115 of file ArenaPoolSTLAllocator.h.

◆ pointer

template<class T , class VETO = T>
typedef T* SG::ArenaPoolSTLAllocator< T, VETO >::pointer

Standard STL allocator typedefs.

Definition at line 109 of file ArenaPoolSTLAllocator.h.

◆ propagate_on_container_copy_assignment

template<class T , class VETO = T>
typedef std::false_type SG::ArenaPoolSTLAllocator< T, VETO >::propagate_on_container_copy_assignment

When we assign to a container, the target should retain its allocator.

Definition at line 118 of file ArenaPoolSTLAllocator.h.

◆ propagate_on_container_move_assignment

template<class T , class VETO = T>
typedef std::true_type SG::ArenaPoolSTLAllocator< T, VETO >::propagate_on_container_move_assignment

Move allocators on move/swap.

Definition at line 121 of file ArenaPoolSTLAllocator.h.

◆ propagate_on_container_swap

template<class T , class VETO = T>
typedef std::true_type SG::ArenaPoolSTLAllocator< T, VETO >::propagate_on_container_swap

Definition at line 122 of file ArenaPoolSTLAllocator.h.

◆ reference

template<class T , class VETO = T>
typedef T& SG::ArenaPoolSTLAllocator< T, VETO >::reference

Definition at line 111 of file ArenaPoolSTLAllocator.h.

◆ size_type

template<class T , class VETO = T>
typedef size_t SG::ArenaPoolSTLAllocator< T, VETO >::size_type

Definition at line 114 of file ArenaPoolSTLAllocator.h.

◆ value_type

template<class T , class VETO = T>
typedef T SG::ArenaPoolSTLAllocator< T, VETO >::value_type

Definition at line 113 of file ArenaPoolSTLAllocator.h.

Constructor & Destructor Documentation

◆ ArenaPoolSTLAllocator() [1/4]

template<class T , class VETO = T>
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator ( size_t  nblock = 1000,
const std::string &  name = "" 
)

Default constructor.

Parameters
nblockValue to set in the parameters structure for the number of elements to allocate per block.
nameValue to set in the parameters structure for the allocator name.

◆ ArenaPoolSTLAllocator() [2/4]

template<class T , class VETO = T>
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator ( const ArenaPoolSTLAllocator< T, VETO > &  a)

Copy constructor.

The name and nblock parameters are copied, but the data are not.

◆ ArenaPoolSTLAllocator() [3/4]

template<class T , class VETO = T>
template<class U , class V >
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator ( const ArenaPoolSTLAllocator< U, V > &  a)

Constructor from another ArenaPoolSTLAllocator.

The name and nblock parameters are copied, but the data are not.

◆ ArenaPoolSTLAllocator() [4/4]

template<class T , class VETO = T>
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator ( ArenaPoolSTLAllocator< T, VETO > &&  a)

Move constructor.

Move the data.

Member Function Documentation

◆ address()

template<class T , class VETO = T>
pointer SG::ArenaPoolSTLAllocator< T, VETO >::address ( reference  x) const

Convert a reference to an address.

◆ allocate()

template<class T , class VETO = T>
pointer SG::ArenaPoolSTLAllocator< T, VETO >::allocate ( size_type  n,
const void *  hint = 0 
)

Allocate new objects.

Parameters
nNumber of objects to allocate. Must be 1.
hintAllocation hint. Not used.

◆ ATH_MEMBER_REQUIRES()

template<class T , class VETO = T>
SG::ArenaPoolSTLAllocator< T, VETO >::ATH_MEMBER_REQUIRES ( std::is_same_v< reference, const_reference >,
const_pointer   
) const
inline

Definition at line 216 of file ArenaPoolSTLAllocator.h.

218  { return &x; }

◆ construct()

template<class T , class VETO = T>
template<class... Args>
void SG::ArenaPoolSTLAllocator< T, VETO >::construct ( pointer  p,
Args &&...  args 
)

Call the T constructor.

Parameters
pLocation of the memory.
argsArguments to pass to the constructor.

◆ deallocate()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::deallocate ( pointer  ,
size_type  n 
)

Deallocate objects.

Parameters
nNumber of objects to deallocate. Must be 1.

This implementation doesn't do anything.

◆ destroy()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::destroy ( pointer  p)

Call the T destructor.

Parameters
pLocation of the memory.

◆ erase()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::erase ( )

Free all allocated elements and release memory back to the system.

All elements allocated are freed, and all allocated blocks of memory are released back to the system. destructor should be called on them if it was provided (preceded by clear if provided and mustClear was set).

◆ max_size()

template<class T , class VETO = T>
size_type SG::ArenaPoolSTLAllocator< T, VETO >::max_size ( ) const
throw (
)

Return the maximum number of objects we can allocate at once.

This always returns 1.

◆ name()

template<class T , class VETO = T>
const std::string& SG::ArenaPoolSTLAllocator< T, VETO >::name ( ) const

Return the name of this allocator.

◆ nblock()

template<class T , class VETO = T>
size_t SG::ArenaPoolSTLAllocator< T, VETO >::nblock ( ) const

Return the hinted number of objects allocated per block.

◆ operator!=()

template<class T , class VETO = T>
bool SG::ArenaPoolSTLAllocator< T, VETO >::operator!= ( const ArenaPoolSTLAllocator< T, VETO > &  other) const

Inequality test.

Two allocators should compare equal if objects allocated by one can be deallocated by the other. We should just check if they are the same object.

◆ operator=()

template<class T , class VETO = T>
ArenaPoolSTLAllocator& SG::ArenaPoolSTLAllocator< T, VETO >::operator= ( ArenaPoolSTLAllocator< T, VETO > &&  a)

Move assignment.

Move the data.

◆ operator==()

template<class T , class VETO = T>
bool SG::ArenaPoolSTLAllocator< T, VETO >::operator== ( const ArenaPoolSTLAllocator< T, VETO > &  other) const

Equality test.

Two allocators should compare equal if objects allocated by one can be deallocated by the other. We should just check if they are the same object.

◆ poolptr()

template<class T , class VETO = T>
const ArenaBlockAllocatorBase* SG::ArenaPoolSTLAllocator< T, VETO >::poolptr ( ) const

Return a pointer to the underlying allocator (may be 0).

◆ protect()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::protect ( )

Write-protect the memory managed by this allocator.

Adjust protection on the memory managed by this allocator to disallow writes.

◆ reserve()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::reserve ( size_t  size)

Set the total number of elements cached by the allocator.

Parameters
sizeThe desired pool size.

This allows changing the number of elements that are currently free but cached. Any allocated elements are not affected by this call.

If size is greater than the total number of elements currently cached, then more will be allocated. This will preferably done with a single block, but that is not guaranteed; in addition, the allocator may allocate more elements than is requested.

If size is smaller than the total number of elements currently cached, as many blocks as possible will be released back to the system. It may not be possible to release the number of elements requested; this should be implemented on a best-effort basis.

◆ reset()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::reset ( )

Free all allocated elements.

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.

◆ select_on_container_copy_construction()

template<class T , class VETO = T>
ArenaPoolSTLAllocator SG::ArenaPoolSTLAllocator< T, VETO >::select_on_container_copy_construction ( ) const

Return allocator to use for a copy-constructed container.

When we copy-construct a container, we want the new allocator to copy parameters from the old one, but not the data.

◆ stats()

template<class T , class VETO = T>
ArenaAllocatorBase::Stats SG::ArenaPoolSTLAllocator< T, VETO >::stats ( ) const

Return the statistics block for this allocator.

◆ swap()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::swap ( ArenaPoolSTLAllocator< T, VETO > &  a)

Swap.

◆ unprotect()

template<class T , class VETO = T>
void SG::ArenaPoolSTLAllocator< T, VETO >::unprotect ( )

Write-enable the memory managed by this allocator.

Adjust protection on the memory managed by this allocator to allow writes.

Member Data Documentation

◆ m_pool

template<class T , class VETO = T>
ArenaPoolAllocator SG::ArenaPoolSTLAllocator< T, VETO >::m_pool
private

The underlying allocator.

Definition at line 348 of file ArenaPoolSTLAllocator.h.


The documentation for this class was generated from the following file:
x
#define x