![]() |
ATLAS Offline Software
|
STL-style allocator wrapper for ArenaPoolAllocator
.
More...
#include <ArenaPoolSTLAllocator.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 | |
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... | |
ArenaPoolSTLAllocator & | operator= (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... | |
template<bool = true> | |
requires (!std::same_as< 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 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 | |
ArenaPoolAllocator | m_pool |
The underlying allocator. More... | |
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.
typedef const T* SG::ArenaPoolSTLAllocator< T, VETO >::const_pointer |
Definition at line 110 of file ArenaPoolSTLAllocator.h.
typedef const T& SG::ArenaPoolSTLAllocator< T, VETO >::const_reference |
Definition at line 112 of file ArenaPoolSTLAllocator.h.
typedef ptrdiff_t SG::ArenaPoolSTLAllocator< T, VETO >::difference_type |
Definition at line 115 of file ArenaPoolSTLAllocator.h.
typedef T* SG::ArenaPoolSTLAllocator< T, VETO >::pointer |
Standard STL allocator typedefs.
Definition at line 109 of file ArenaPoolSTLAllocator.h.
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.
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.
typedef std::true_type SG::ArenaPoolSTLAllocator< T, VETO >::propagate_on_container_swap |
Definition at line 122 of file ArenaPoolSTLAllocator.h.
typedef T& SG::ArenaPoolSTLAllocator< T, VETO >::reference |
Definition at line 111 of file ArenaPoolSTLAllocator.h.
typedef size_t SG::ArenaPoolSTLAllocator< T, VETO >::size_type |
Definition at line 114 of file ArenaPoolSTLAllocator.h.
typedef T SG::ArenaPoolSTLAllocator< T, VETO >::value_type |
Definition at line 113 of file ArenaPoolSTLAllocator.h.
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator | ( | size_t | nblock = 1000 , |
const std::string & | name = "" |
||
) |
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator | ( | const ArenaPoolSTLAllocator< T, VETO > & | a | ) |
Copy constructor.
The name
and nblock
parameters are copied, but the data are not.
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.
SG::ArenaPoolSTLAllocator< T, VETO >::ArenaPoolSTLAllocator | ( | ArenaPoolSTLAllocator< T, VETO > && | a | ) |
Move constructor.
Move the data.
pointer SG::ArenaPoolSTLAllocator< T, VETO >::address | ( | reference | x | ) | const |
Convert a reference to an address.
pointer SG::ArenaPoolSTLAllocator< 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. |
void SG::ArenaPoolSTLAllocator< T, VETO >::construct | ( | pointer | p, |
Args &&... | args | ||
) |
Call the T
constructor.
p | Location of the memory. |
args | Arguments to pass to the constructor. |
void SG::ArenaPoolSTLAllocator< T, VETO >::deallocate | ( | pointer | , |
size_type | n | ||
) |
Deallocate objects.
n | Number of objects to deallocate. Must be 1. |
This implementation doesn't do anything.
void SG::ArenaPoolSTLAllocator< T, VETO >::destroy | ( | pointer | p | ) |
Call the T
destructor.
p | Location of the memory. |
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).
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.
const std::string& SG::ArenaPoolSTLAllocator< T, VETO >::name | ( | ) | const |
Return the name of this allocator.
size_t SG::ArenaPoolSTLAllocator< T, VETO >::nblock | ( | ) | const |
Return the hinted number of objects allocated per block.
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.
ArenaPoolSTLAllocator& SG::ArenaPoolSTLAllocator< T, VETO >::operator= | ( | ArenaPoolSTLAllocator< T, VETO > && | a | ) |
Move assignment.
Move the data.
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.
const ArenaBlockAllocatorBase* SG::ArenaPoolSTLAllocator< T, VETO >::poolptr | ( | ) | const |
Return a pointer to the underlying allocator (may be 0).
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.
|
inline |
Definition at line 217 of file ArenaPoolSTLAllocator.h.
void SG::ArenaPoolSTLAllocator< 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::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.
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.
ArenaAllocatorBase::Stats SG::ArenaPoolSTLAllocator< T, VETO >::stats | ( | ) | const |
Return the statistics block for this allocator.
void SG::ArenaPoolSTLAllocator< T, VETO >::swap | ( | ArenaPoolSTLAllocator< T, VETO > & | a | ) |
Swap.
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.
|
private |
The underlying allocator.
Definition at line 349 of file ArenaPoolSTLAllocator.h.