ATLAS Offline Software
|
STL-style allocator wrapper for ArenaHeapAllocator
.
More...
#include <ArenaHeapSTLAllocator.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 | |
ArenaHeapSTLAllocator (size_t nblock=1000, const std::string &name="") | |
Default constructor. More... | |
ArenaHeapSTLAllocator (const ArenaHeapSTLAllocator &a) | |
Copy constructor. More... | |
template<class U , class V > | |
ArenaHeapSTLAllocator (const ArenaHeapSTLAllocator< U, V > &a) | |
Constructor from another ArenaHeapSTLAllocator . More... | |
ArenaHeapSTLAllocator (ArenaHeapSTLAllocator &&a) | |
Move constructor. More... | |
ArenaHeapSTLAllocator & | operator= (ArenaHeapSTLAllocator &&a) |
Move assignment. More... | |
void | swap (ArenaHeapSTLAllocator &a) |
Swap. More... | |
ArenaHeapSTLAllocator | select_on_container_copy_construction () const |
Return allocator to use for a copy-constructed container. More... | |
bool | operator== (const ArenaHeapSTLAllocator &other) const |
Equality test. More... | |
bool | operator!= (const ArenaHeapSTLAllocator &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... | |
const ArenaBlockAllocatorBase * | poolptr () 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 | |
ArenaHeapAllocator | m_pool |
The underlying allocator. More... | |
STL-style allocator wrapper for ArenaHeapAllocator
.
This is the generic specialization, which uses the heap allocator.
See the file-level comments for details.
Definition at line 94 of file ArenaHeapSTLAllocator.h.
typedef const T* SG::ArenaHeapSTLAllocator< T, VETO >::const_pointer |
Definition at line 99 of file ArenaHeapSTLAllocator.h.
typedef const T& SG::ArenaHeapSTLAllocator< T, VETO >::const_reference |
Definition at line 101 of file ArenaHeapSTLAllocator.h.
typedef ptrdiff_t SG::ArenaHeapSTLAllocator< T, VETO >::difference_type |
Definition at line 104 of file ArenaHeapSTLAllocator.h.
typedef T* SG::ArenaHeapSTLAllocator< T, VETO >::pointer |
Standard STL allocator typedefs.
Definition at line 98 of file ArenaHeapSTLAllocator.h.
typedef std::false_type SG::ArenaHeapSTLAllocator< T, VETO >::propagate_on_container_copy_assignment |
When we assign to a container, the target should retain its allocator.
Definition at line 107 of file ArenaHeapSTLAllocator.h.
typedef std::true_type SG::ArenaHeapSTLAllocator< T, VETO >::propagate_on_container_move_assignment |
Move allocators on move/swap.
Definition at line 110 of file ArenaHeapSTLAllocator.h.
typedef std::true_type SG::ArenaHeapSTLAllocator< T, VETO >::propagate_on_container_swap |
Definition at line 111 of file ArenaHeapSTLAllocator.h.
typedef T& SG::ArenaHeapSTLAllocator< T, VETO >::reference |
Definition at line 100 of file ArenaHeapSTLAllocator.h.
typedef size_t SG::ArenaHeapSTLAllocator< T, VETO >::size_type |
Definition at line 103 of file ArenaHeapSTLAllocator.h.
typedef T SG::ArenaHeapSTLAllocator< T, VETO >::value_type |
Definition at line 102 of file ArenaHeapSTLAllocator.h.
SG::ArenaHeapSTLAllocator< T, VETO >::ArenaHeapSTLAllocator | ( | size_t | nblock = 1000 , |
const std::string & | name = "" |
||
) |
SG::ArenaHeapSTLAllocator< T, VETO >::ArenaHeapSTLAllocator | ( | const ArenaHeapSTLAllocator< T, VETO > & | a | ) |
Copy constructor.
The name
and nblock
parameters are copied, but the data are not.
SG::ArenaHeapSTLAllocator< T, VETO >::ArenaHeapSTLAllocator | ( | const ArenaHeapSTLAllocator< U, V > & | a | ) |
Constructor from another ArenaHeapSTLAllocator
.
The name
and nblock
parameters are copied, but the data are not.
SG::ArenaHeapSTLAllocator< T, VETO >::ArenaHeapSTLAllocator | ( | ArenaHeapSTLAllocator< T, VETO > && | a | ) |
Move constructor.
Move the data.
pointer SG::ArenaHeapSTLAllocator< T, VETO >::address | ( | reference | x | ) | const |
Convert a reference to an address.
pointer SG::ArenaHeapSTLAllocator< T, VETO >::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 204 of file ArenaHeapSTLAllocator.h.
void SG::ArenaHeapSTLAllocator< T, VETO >::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 223 of file ArenaHeapSTLAllocator.h.
void SG::ArenaHeapSTLAllocator< T, VETO >::deallocate | ( | pointer | , |
size_type | n | ||
) |
Deallocate objects.
n | Number of objects to deallocate. Must be 1. |
void SG::ArenaHeapSTLAllocator< T, VETO >::destroy | ( | pointer | p | ) |
Call the T
destructor.
p | Location of the memory. |
void SG::ArenaHeapSTLAllocator< 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).
size_type SG::ArenaHeapSTLAllocator< T, VETO >::max_size | ( | ) | const | |
throw | ( | |||
) |
Return the maximum number of objects we can allocate at once.
This always returns 1.
const std::string& SG::ArenaHeapSTLAllocator< T, VETO >::name | ( | ) | const |
Return the name of this allocator.
size_t SG::ArenaHeapSTLAllocator< T, VETO >::nblock | ( | ) | const |
Return the hinted number of objects allocated per block.
bool SG::ArenaHeapSTLAllocator< T, VETO >::operator!= | ( | const ArenaHeapSTLAllocator< 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.
ArenaHeapSTLAllocator& SG::ArenaHeapSTLAllocator< T, VETO >::operator= | ( | ArenaHeapSTLAllocator< T, VETO > && | a | ) |
Move assignment.
Move the data.
bool SG::ArenaHeapSTLAllocator< T, VETO >::operator== | ( | const ArenaHeapSTLAllocator< 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.
const ArenaBlockAllocatorBase* SG::ArenaHeapSTLAllocator< T, VETO >::poolptr | ( | ) | const |
Return a pointer to the underlying allocator (may be 0).
void SG::ArenaHeapSTLAllocator< T, VETO >::protect | ( | ) |
Write-protect the memory managed by this allocator.
Adjust protection on the memory managed by this allocator to disallow writes.
void SG::ArenaHeapSTLAllocator< T, VETO >::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::ArenaHeapSTLAllocator< 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.
ArenaHeapSTLAllocator SG::ArenaHeapSTLAllocator< 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.
ArenaAllocatorBase::Stats SG::ArenaHeapSTLAllocator< T, VETO >::stats | ( | ) | const |
Return the statistics block for this allocator.
void SG::ArenaHeapSTLAllocator< T, VETO >::swap | ( | ArenaHeapSTLAllocator< T, VETO > & | a | ) |
Swap.
void SG::ArenaHeapSTLAllocator< T, VETO >::unprotect | ( | ) |
Write-enable the memory managed by this allocator.
Adjust protection on the memory managed by this allocator to allow writes.
|
private |
The underlying allocator.
Definition at line 340 of file ArenaHeapSTLAllocator.h.