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

Forward declaration. More...

#include <ArenaSharedHeapSTLAllocator.h>

Collaboration diagram for SG::ArenaSharedHeapSTLAllocator< T >:

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

 ArenaSharedHeapSTLAllocator (size_t nblock=1000)
 Default constructor. More...
 
 ArenaSharedHeapSTLAllocator (const ArenaSharedHeapSTLAllocator &a)
 Copy constructor. More...
 
 ArenaSharedHeapSTLAllocator (ArenaSharedHeapSTLAllocator &&a)=default
 Move constructor is the same as the copy constructor. More...
 
template<class U >
 ArenaSharedHeapSTLAllocator (const ArenaSharedHeapSTLAllocator< U > &a)
 Constructor from another ArenaSharedHeapSTLAllocator. More...
 
 ~ArenaSharedHeapSTLAllocator ()
 Destructor. More...
 
ArenaSharedHeapSTLAllocatoroperator= (const ArenaSharedHeapSTLAllocator &a)
 Assignment. More...
 
ArenaSharedHeapSTLAllocatoroperator= (ArenaSharedHeapSTLAllocator &&a)
 Move assignment. More...
 
void swap (ArenaSharedHeapSTLAllocator &a)
 Swap. More...
 
bool operator== (const ArenaSharedHeapSTLAllocator &other) const
 Equality test. More...
 
bool operator!= (const ArenaSharedHeapSTLAllocator &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...
 
 deallocate (const_pointer p, size_type n) const
 
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...
 
ArenaAllocatorBase::Stats totstats () const
 Return the statistics blocks summed up over all allocators using this pool. More...
 
ArenaHeapAllocatorpoolptr ()
 Return a pointer to the underlying allocator. More...
 
const ArenaHeapAllocatorpoolptr () const
 Return a pointer to the underlying allocator. More...
 
void report (std::ostream &os) const
 Generate printable report for all contained allocators. More...
 
void protect ()
 Write-protect the memory managed by these allocators. More...
 
void unprotect ()
 Write-enable the memory managed by these allocators. More...
 

Private Attributes

ArenaSharedHeapSTLHeaderm_header
 
ArenaHeapAllocatorm_pool
 

Friends

template<class U >
class ArenaSharedHeapSTLAllocator
 Make all instantiations of this class friends (to be able to copy the header pointer). More...
 

Detailed Description

template<class T>
class SG::ArenaSharedHeapSTLAllocator< T >

Forward declaration.

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

See the file-level comments for details.

Definition at line 75 of file ArenaSharedHeapSTLAllocator.h.

Member Typedef Documentation

◆ const_pointer

template<class T >
typedef const T* SG::ArenaSharedHeapSTLAllocator< T >::const_pointer

Definition at line 211 of file ArenaSharedHeapSTLAllocator.h.

◆ const_reference

template<class T >
typedef const T& SG::ArenaSharedHeapSTLAllocator< T >::const_reference

Definition at line 213 of file ArenaSharedHeapSTLAllocator.h.

◆ difference_type

template<class T >
typedef ptrdiff_t SG::ArenaSharedHeapSTLAllocator< T >::difference_type

Definition at line 216 of file ArenaSharedHeapSTLAllocator.h.

◆ pointer

template<class T >
typedef T* SG::ArenaSharedHeapSTLAllocator< T >::pointer

Standard STL allocator typedefs.

Definition at line 210 of file ArenaSharedHeapSTLAllocator.h.

◆ propagate_on_container_copy_assignment

template<class T >
typedef std::false_type SG::ArenaSharedHeapSTLAllocator< T >::propagate_on_container_copy_assignment

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

Definition at line 219 of file ArenaSharedHeapSTLAllocator.h.

◆ propagate_on_container_move_assignment

template<class T >
typedef std::true_type SG::ArenaSharedHeapSTLAllocator< T >::propagate_on_container_move_assignment

Move allocators on move/swap.

Definition at line 222 of file ArenaSharedHeapSTLAllocator.h.

◆ propagate_on_container_swap

template<class T >
typedef std::true_type SG::ArenaSharedHeapSTLAllocator< T >::propagate_on_container_swap

Definition at line 223 of file ArenaSharedHeapSTLAllocator.h.

◆ reference

template<class T >
typedef T& SG::ArenaSharedHeapSTLAllocator< T >::reference

Definition at line 212 of file ArenaSharedHeapSTLAllocator.h.

◆ size_type

template<class T >
typedef size_t SG::ArenaSharedHeapSTLAllocator< T >::size_type

Definition at line 215 of file ArenaSharedHeapSTLAllocator.h.

◆ value_type

template<class T >
typedef T SG::ArenaSharedHeapSTLAllocator< T >::value_type

Definition at line 214 of file ArenaSharedHeapSTLAllocator.h.

Constructor & Destructor Documentation

◆ ArenaSharedHeapSTLAllocator() [1/4]

template<class T >
SG::ArenaSharedHeapSTLAllocator< T >::ArenaSharedHeapSTLAllocator ( size_t  nblock = 1000)

Default constructor.

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

◆ ArenaSharedHeapSTLAllocator() [2/4]

Copy constructor.

The new STL allocator will reference the same set of underlying Arena allocators as the old one.

◆ ArenaSharedHeapSTLAllocator() [3/4]

Move constructor is the same as the copy constructor.

◆ ArenaSharedHeapSTLAllocator() [4/4]

template<class T >
template<class U >
SG::ArenaSharedHeapSTLAllocator< T >::ArenaSharedHeapSTLAllocator ( const ArenaSharedHeapSTLAllocator< U > &  a)

Constructor from another ArenaSharedHeapSTLAllocator.

The new STL allocator will reference the same set of underlying Arena allocators as the old one.

◆ ~ArenaSharedHeapSTLAllocator()

Destructor.

Member Function Documentation

◆ address()

template<class T >
pointer SG::ArenaSharedHeapSTLAllocator< T >::address ( reference  x) const

Convert a reference to an address.

◆ allocate()

template<class T >
pointer SG::ArenaSharedHeapSTLAllocator< T >::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 >
SG::ArenaSharedHeapSTLAllocator< T >::ATH_MEMBER_REQUIRES ( std::is_same_v< reference, const_reference >,
const_pointer   
) const
inline

Definition at line 320 of file ArenaSharedHeapSTLAllocator.h.

322  { return &x; }

◆ construct()

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

Call the T constructor.

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

◆ deallocate() [1/2]

template<class T >
SG::ArenaSharedHeapSTLAllocator< T >::deallocate ( const_pointer  p,
size_type  n 
) const
inline

Definition at line 339 of file ArenaSharedHeapSTLAllocator.h.

340  {
341  pointer p_nc ATLAS_THREAD_SAFE = const_cast<pointer>(p);
342  deallocate (p_nc, n);
343  }

◆ deallocate() [2/2]

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::deallocate ( pointer  ,
size_type  n 
)

Deallocate objects.

Parameters
nNumber of objects to deallocate. Must be 1.

◆ destroy()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::destroy ( pointer  p)

Call the T destructor.

Parameters
pLocation of the memory.

◆ erase()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::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 >
size_type SG::ArenaSharedHeapSTLAllocator< T >::max_size ( ) const
throw (
)

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

This always returns 1.

◆ name()

template<class T >
const std::string& SG::ArenaSharedHeapSTLAllocator< T >::name ( ) const

Return the name of this allocator.

◆ nblock()

template<class T >
size_t SG::ArenaSharedHeapSTLAllocator< T >::nblock ( ) const

Return the hinted number of objects allocated per block.

◆ operator!=()

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

Inequality test.

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

◆ operator=() [1/2]

Move assignment.

This allows assignment between different arenas.

◆ operator=() [2/2]

Assignment.

We allow assignment only if the two objects involved represent the same arena, in which case it's a no-op. In other cases, we raise an exception.

◆ operator==()

template<class T >
bool SG::ArenaSharedHeapSTLAllocator< T >::operator== ( const ArenaSharedHeapSTLAllocator< T > &  other) const

Equality test.

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

◆ poolptr() [1/2]

template<class T >
ArenaHeapAllocator* SG::ArenaSharedHeapSTLAllocator< T >::poolptr ( )

Return a pointer to the underlying allocator.

◆ poolptr() [2/2]

template<class T >
const ArenaHeapAllocator* SG::ArenaSharedHeapSTLAllocator< T >::poolptr ( ) const

Return a pointer to the underlying allocator.

◆ protect()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::protect ( )

Write-protect the memory managed by these allocators.

Adjust protection on the memory managed by these allocators to disallow writes.

◆ report()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::report ( std::ostream &  os) const

Generate printable report for all contained allocators.

Parameters
osStream to which to write the report.

◆ reserve()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::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 >
void SG::ArenaSharedHeapSTLAllocator< T >::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.

◆ stats()

template<class T >
ArenaAllocatorBase::Stats SG::ArenaSharedHeapSTLAllocator< T >::stats ( ) const

Return the statistics block for this allocator.

◆ swap()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::swap ( ArenaSharedHeapSTLAllocator< T > &  a)

Swap.

◆ totstats()

template<class T >
ArenaAllocatorBase::Stats SG::ArenaSharedHeapSTLAllocator< T >::totstats ( ) const

Return the statistics blocks summed up over all allocators using this pool.

◆ unprotect()

template<class T >
void SG::ArenaSharedHeapSTLAllocator< T >::unprotect ( )

Write-enable the memory managed by these allocators.

Adjust protection on the memory managed by these allocators to allow writes.

Friends And Related Function Documentation

◆ ArenaSharedHeapSTLAllocator

template<class T >
template<class U >
friend class ArenaSharedHeapSTLAllocator
friend

Make all instantiations of this class friends (to be able to copy the header pointer).

Definition at line 207 of file ArenaSharedHeapSTLAllocator.h.

Member Data Documentation

◆ m_header

template<class T >
ArenaSharedHeapSTLHeader* SG::ArenaSharedHeapSTLAllocator< T >::m_header
private

Definition at line 475 of file ArenaSharedHeapSTLAllocator.h.

◆ m_pool

template<class T >
ArenaHeapAllocator* SG::ArenaSharedHeapSTLAllocator< T >::m_pool
private

Definition at line 476 of file ArenaSharedHeapSTLAllocator.h.


The documentation for this class was generated from the following file:
x
#define x
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
beamspotman.n
n
Definition: beamspotman.py:731
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SG::ArenaSharedHeapSTLAllocator::deallocate
void deallocate(pointer, size_type n)
Deallocate objects.
SG::ArenaSharedHeapSTLAllocator::pointer
T * pointer
Standard STL allocator typedefs.
Definition: ArenaSharedHeapSTLAllocator.h:210