ATLAS Offline Software
|
Forward declaration. More...
#include <ArenaSharedHeapSTLAllocator.h>
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... | |
ArenaSharedHeapSTLAllocator & | operator= (const ArenaSharedHeapSTLAllocator &a) |
Assignment. More... | |
ArenaSharedHeapSTLAllocator & | operator= (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... | |
ArenaHeapAllocator * | poolptr () |
Return a pointer to the underlying allocator. More... | |
const ArenaHeapAllocator * | poolptr () 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 | |
ArenaSharedHeapSTLHeader * | m_header |
ArenaHeapAllocator * | m_pool |
Friends | |
template<class U > | |
class | ArenaSharedHeapSTLAllocator |
Make all instantiations of this class friends (to be able to copy the header pointer). More... | |
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.
typedef const T* SG::ArenaSharedHeapSTLAllocator< T >::const_pointer |
Definition at line 211 of file ArenaSharedHeapSTLAllocator.h.
typedef const T& SG::ArenaSharedHeapSTLAllocator< T >::const_reference |
Definition at line 213 of file ArenaSharedHeapSTLAllocator.h.
typedef ptrdiff_t SG::ArenaSharedHeapSTLAllocator< T >::difference_type |
Definition at line 216 of file ArenaSharedHeapSTLAllocator.h.
typedef T* SG::ArenaSharedHeapSTLAllocator< T >::pointer |
Standard STL allocator typedefs.
Definition at line 210 of file ArenaSharedHeapSTLAllocator.h.
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.
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.
typedef std::true_type SG::ArenaSharedHeapSTLAllocator< T >::propagate_on_container_swap |
Definition at line 223 of file ArenaSharedHeapSTLAllocator.h.
typedef T& SG::ArenaSharedHeapSTLAllocator< T >::reference |
Definition at line 212 of file ArenaSharedHeapSTLAllocator.h.
typedef size_t SG::ArenaSharedHeapSTLAllocator< T >::size_type |
Definition at line 215 of file ArenaSharedHeapSTLAllocator.h.
typedef T SG::ArenaSharedHeapSTLAllocator< T >::value_type |
Definition at line 214 of file ArenaSharedHeapSTLAllocator.h.
SG::ArenaSharedHeapSTLAllocator< T >::ArenaSharedHeapSTLAllocator | ( | size_t | nblock = 1000 | ) |
SG::ArenaSharedHeapSTLAllocator< T >::ArenaSharedHeapSTLAllocator | ( | const ArenaSharedHeapSTLAllocator< T > & | a | ) |
Copy constructor.
The new STL allocator will reference the same set of underlying Arena allocators as the old one.
|
default |
Move constructor is the same as the copy constructor.
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.
SG::ArenaSharedHeapSTLAllocator< T >::~ArenaSharedHeapSTLAllocator | ( | ) |
Destructor.
pointer SG::ArenaSharedHeapSTLAllocator< T >::address | ( | reference | x | ) | const |
Convert a reference to an address.
pointer SG::ArenaSharedHeapSTLAllocator< T >::allocate | ( | size_type | n, |
const void * | hint = 0 |
||
) |
Allocate new objects.
n | Number of objects to allocate. Must be 1. |
hint | Allocation hint. Not used. |
|
inline |
Definition at line 320 of file ArenaSharedHeapSTLAllocator.h.
void SG::ArenaSharedHeapSTLAllocator< T >::construct | ( | pointer | p, |
Args &&... | args | ||
) |
Call the T
constructor.
p | Location of the memory. |
args | Arguments to pass to the constructor. |
|
inline |
Definition at line 339 of file ArenaSharedHeapSTLAllocator.h.
void SG::ArenaSharedHeapSTLAllocator< T >::deallocate | ( | pointer | , |
size_type | n | ||
) |
Deallocate objects.
n | Number of objects to deallocate. Must be 1. |
void SG::ArenaSharedHeapSTLAllocator< T >::destroy | ( | pointer | p | ) |
Call the T
destructor.
p | Location of the memory. |
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).
size_type SG::ArenaSharedHeapSTLAllocator< T >::max_size | ( | ) | const | |
throw | ( | |||
) |
Return the maximum number of objects we can allocate at once.
This always returns 1.
const std::string& SG::ArenaSharedHeapSTLAllocator< T >::name | ( | ) | const |
Return the name of this allocator.
size_t SG::ArenaSharedHeapSTLAllocator< T >::nblock | ( | ) | const |
Return the hinted number of objects allocated per block.
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.
ArenaSharedHeapSTLAllocator& SG::ArenaSharedHeapSTLAllocator< T >::operator= | ( | ArenaSharedHeapSTLAllocator< T > && | a | ) |
Move assignment.
This allows assignment between different arenas.
ArenaSharedHeapSTLAllocator& SG::ArenaSharedHeapSTLAllocator< T >::operator= | ( | const ArenaSharedHeapSTLAllocator< T > & | a | ) |
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.
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.
ArenaHeapAllocator* SG::ArenaSharedHeapSTLAllocator< T >::poolptr | ( | ) |
Return a pointer to the underlying allocator.
const ArenaHeapAllocator* SG::ArenaSharedHeapSTLAllocator< T >::poolptr | ( | ) | const |
Return a pointer to the underlying allocator.
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.
void SG::ArenaSharedHeapSTLAllocator< T >::report | ( | std::ostream & | os | ) | const |
Generate printable report for all contained allocators.
os | Stream to which to write the report. |
void SG::ArenaSharedHeapSTLAllocator< T >::reserve | ( | size_t | size | ) |
Set the total number of elements cached by the allocator.
size | The 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.
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.
ArenaAllocatorBase::Stats SG::ArenaSharedHeapSTLAllocator< T >::stats | ( | ) | const |
Return the statistics block for this allocator.
void SG::ArenaSharedHeapSTLAllocator< T >::swap | ( | ArenaSharedHeapSTLAllocator< T > & | a | ) |
Swap.
ArenaAllocatorBase::Stats SG::ArenaSharedHeapSTLAllocator< T >::totstats | ( | ) | const |
Return the statistics blocks summed up over all allocators using this pool.
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.
Make all instantiations of this class friends (to be able to copy the header pointer).
Definition at line 207 of file ArenaSharedHeapSTLAllocator.h.
|
private |
Definition at line 475 of file ArenaSharedHeapSTLAllocator.h.
|
private |
Definition at line 476 of file ArenaSharedHeapSTLAllocator.h.