Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ArenaHeapSTLAllocator.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 */
41 #ifndef ATLALLOCATORS_ARENAHEAPSTLALLOCATOR
42 #define ATLALLOCATORS_ARENAHEAPSTLALLOCATOR
43 
44 
47 #include <string>
48 #include <cstddef>
49 
50 
51 namespace SG {
52 
53 
59 template <class T>
61  : public ArenaHeapAllocator::initParams<T, false, true, true>
62 {
63 public:
66 
74  ArenaHeapSTLAllocator_initParams (size_t nblock = 1000,
75  const std::string& name = "");
76 
79 
81  // Note: gcc 3.2.3 doesn't allow defining this out-of-line.
82  operator ArenaAllocatorBase::Params() const { return params(); }
83 };
84 
85 
92 template <class T, class VETO=T>
94 {
95 public:
97  typedef T* pointer;
98  typedef const T* const_pointer;
99  typedef T& reference;
100  typedef const T& const_reference;
101  typedef T value_type;
102  typedef size_t size_type;
103  typedef ptrdiff_t difference_type;
104 
106  typedef std::false_type propagate_on_container_copy_assignment;
107 
110  typedef std::true_type propagate_on_container_swap;
111 
112 
114  template <class U> struct rebind {
116  };
117 
118 
126  ArenaHeapSTLAllocator (size_t nblock = 1000, const std::string& name = "");
127 
128 
135 
136 
142  template <class U, class V>
144 
145 
152 
153 
160 
161 
166 
167 
175 
176 
185 
186 
195 
196 
197  // We don't bother to supply a more general constructor --- shouldn't
198  // be needed.
199 
200 
203  template <bool = true>
204  requires (!std::same_as<reference,const_reference>)
206  address (const_reference x) const { return &x; }
207 
208 
214  pointer allocate (size_type n, const void* hint = 0);
215 
216 
222  template <bool = true>
223  requires (!std::same_as<reference,const_reference>)
224  void
226  {
227  pointer p_nc ATLAS_THREAD_SAFE = const_cast<pointer>(p);
228  deallocate (p_nc, n);
229  }
230 
231 
237  size_type max_size() const throw();
238 
239 
245  template <class... Args>
246  void construct (pointer p, Args&&... args);
247 
248 
253  void destroy (pointer p);
254 
255 
259  size_t nblock() const;
260 
261 
265  const std::string& name() const;
266 
267 
276  void reset();
277 
278 
287  void erase();
288 
289 
307  void reserve (size_t size);
308 
309 
314 
315 
320 
321 
328  void protect();
329 
330 
337  void unprotect();
338 
339 
340 private:
343 };
344 
345 
346 
348 template <class T>
350 
351 
371 template <class T>
373  : public std::allocator<T>
374 {
375 public:
376  typedef std::allocator<T> base;
377 
379  typedef typename base::value_type value_type;
380  typedef typename base::size_type size_type;
381  typedef typename base::difference_type difference_type;
382 
383 
385  template <class U> struct rebind {
387  };
388 
389 
397  ArenaHeapSTLAllocator (size_t nblock = 1000, const std::string& name = "");
398 
399 
405  template <class U, class V>
407 
408 
409  // We don't bother to supply a more general constructor --- shouldn't
410  // be needed.
411 
412 
416  size_t nblock() const;
417 
418 
422  const std::string& name() const;
423 
424 
429 
430 
435 
436 
442  template <class CONT>
443  static
445 
446 
447 private:
449  size_t m_nblock;
450 
452  std::string m_name;
453 
456 };
457 
458 
465 template <class T>
467  : public ArenaHeapSTLAllocator<T, T>
468 {
469 public:
475  template <class U, class V>
477  ArenaBlockAllocatorBase* poolptr_nc);
478 
479 
488  void reset();
489 
490 
499  void erase();
500 
501 
519  void reserve (size_t size);
520 
521 
528  void protect();
529 
530 
537  void unprotect();
538 
539 
540 private:
543 };
544 
545 
554 template <class T, class VETO>
556 
557 
558 } // namespace SG
559 
560 
562 
563 
564 #endif // ATLALLOCATORS_ARENAHEAPSTLALLOCATOR
SG::ArenaHeapSTLAllocator::allocate
pointer allocate(size_type n, const void *hint=0)
Allocate new objects.
SG::ArenaHeapSTLAllocator_initParams::params
ArenaAllocatorBase::Params params() const
Return an initialized parameters structure.
SG::ArenaHeapSTLAllocator< T, T >::m_nblock
size_t m_nblock
Saved hinted number of objects per block.
Definition: ArenaHeapSTLAllocator.h:449
SG::ArenaHeapSTLAllocator::rebind::other
ArenaHeapSTLAllocator< U, VETO > other
Definition: ArenaHeapSTLAllocator.h:115
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaHeapSTLAllocator::operator==
bool operator==(const ArenaHeapSTLAllocator &other) const
Equality test.
SG::ArenaHeapSTLAllocator< T, T >::size_type
base::size_type size_type
Definition: ArenaHeapSTLAllocator.h:380
SG::ArenaHeapSTLAllocator::size_type
size_t size_type
Definition: ArenaHeapSTLAllocator.h:102
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:45
SG::ArenaHeapSTLAllocator::requires
requires(!std::same_as< reference, const_reference >) void deallocate(const_pointer p
SG::ArenaNonConstHeapSTLAllocator::reset
void reset()
Free all allocated elements.
SG::ArenaNonConstHeapSTLAllocator::protect
void protect()
Write-protect the memory managed by this allocator.
SG::ArenaHeapSTLAllocator::propagate_on_container_move_assignment
std::true_type propagate_on_container_move_assignment
Move allocators on move/swap.
Definition: ArenaHeapSTLAllocator.h:109
SG::ArenaHeapAllocator
Heap-based allocator.
Definition: ArenaHeapAllocator.h:64
SG::ArenaHeapSTLAllocator
STL-style allocator wrapper for ArenaHeapAllocator.
Definition: ArenaHeapSTLAllocator.h:94
taskman.template
dictionary template
Definition: taskman.py:317
SG::ArenaHeapSTLAllocator::const_reference
const T & const_reference
Definition: ArenaHeapSTLAllocator.h:100
SG::ArenaHeapSTLAllocator::const_pointer
const T * const_pointer
Definition: ArenaHeapSTLAllocator.h:98
SG::ArenaNonConstHeapSTLAllocator::reserve
void reserve(size_t size)
Set the total number of elements cached by the allocator.
SG::ArenaHeapSTLAllocator< T, T >::base
std::allocator< T > base
Definition: ArenaHeapSTLAllocator.h:376
SG::ArenaHeapSTLAllocator::rebind
Standard STL allocator rebinder.
Definition: ArenaHeapSTLAllocator.h:114
SG::ArenaHeapSTLAllocator::requires
requires(!std::same_as< reference, const_reference >) const _pointer address(const_reference x) const
Definition: ArenaHeapSTLAllocator.h:204
SG::maybeUnprotect
void maybeUnprotect(ArenaHeapSTLAllocator< T, VETO > &a)
Hook for unprotecting an arena.
SG::ArenaHeapSTLAllocator_initParams::ArenaHeapSTLAllocator_initParams
ArenaHeapSTLAllocator_initParams(size_t nblock=1000, const std::string &name="")
Constructor.
SG::ArenaNonConstHeapSTLAllocator::erase
void erase()
Free all allocated elements and release memory back to the system.
Args
Definition: test_lwtnn_fastgraph.cxx:12
SG::ArenaHeapSTLAllocator< T, T >::value_type
base::value_type value_type
Standard STL allocator typedefs.
Definition: ArenaHeapSTLAllocator.h:379
x
#define x
SG::ArenaHeapSTLAllocator::select_on_container_copy_construction
ArenaHeapSTLAllocator select_on_container_copy_construction() const
Return allocator to use for a copy-constructed container.
SG::ArenaHeapSTLAllocator< T, T >::ArenaHeapSTLAllocator
ArenaHeapSTLAllocator(const ArenaHeapSTLAllocator< U, V > &a)
Constructor from another ArenaHeapSTLAllocator.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::ArenaHeapSTLAllocator::deallocate
void deallocate(pointer, size_type n)
Deallocate objects.
SG::ArenaHeapSTLAllocator::pointer
T * pointer
Standard STL allocator typedefs.
Definition: ArenaHeapSTLAllocator.h:97
SG::ArenaAllocatorBase::Stats
Statistics for an allocator.
Definition: ArenaAllocatorBase.h:188
SG::ArenaHeapSTLAllocator::construct
void construct(pointer p, Args &&... args)
Call the T constructor.
beamspotman.n
n
Definition: beamspotman.py:731
SG::ArenaHeapSTLAllocator< T, T >::rebind::other
ArenaHeapSTLAllocator< U, T > other
Definition: ArenaHeapSTLAllocator.h:386
SG::ArenaHeapSTLAllocator< T, T >::difference_type
base::difference_type difference_type
Definition: ArenaHeapSTLAllocator.h:381
SG::ArenaNonConstHeapSTLAllocator::ArenaNonConstHeapSTLAllocator
ArenaNonConstHeapSTLAllocator(const ArenaHeapSTLAllocator< U, V > &a, ArenaBlockAllocatorBase *poolptr_nc)
Constructor.
SG::ArenaAllocatorBase
Common base class for arena allocator classes.
Definition: ArenaAllocatorBase.h:134
SG::ArenaHeapSTLAllocator_initParams
Initializer for pool allocator parameters.
Definition: ArenaHeapSTLAllocator.h:62
SG::ArenaHeapSTLAllocator::ArenaHeapSTLAllocator
ArenaHeapSTLAllocator(ArenaHeapSTLAllocator &&a)
Move constructor.
SG::ArenaHeapSTLAllocator::address
pointer address(reference x) const
Convert a reference to an address.
ArenaHeapSTLAllocator.icc
SG::ArenaHeapSTLAllocator::name
const std::string & name() const
Return the name of this allocator.
SG::ArenaHeapSTLAllocator::reserve
void reserve(size_t size)
Set the total number of elements cached by the allocator.
SG::ArenaHeapSTLAllocator< T, T >::name
const std::string & name() const
Return the name of this allocator.
SG::ArenaHeapSTLAllocator< T, T >::stats
ArenaAllocatorBase::Stats stats() const
Return the statistics block for this allocator.
SG::ArenaBlockAllocatorBase
Common functionality for block-oriented allocators.
Definition: ArenaBlockAllocatorBase.h:35
SG::ArenaHeapSTLAllocator::ArenaHeapSTLAllocator
ArenaHeapSTLAllocator(size_t nblock=1000, const std::string &name="")
Default constructor.
SG::ArenaHeapSTLAllocator::reference
T & reference
Definition: ArenaHeapSTLAllocator.h:99
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::ArenaHeapSTLAllocator::operator!=
bool operator!=(const ArenaHeapSTLAllocator &other) const
Inequality test.
SG::ArenaNonConstHeapSTLAllocator
Forward declaration.
Definition: ArenaHeapSTLAllocator.h:349
SG::ArenaHeapSTLAllocator::erase
void erase()
Free all allocated elements and release memory back to the system.
SG::ArenaHeapSTLAllocator< T, T >::nblock
size_t nblock() const
Return the hinted number of objects allocated per block.
SG::ArenaHeapSTLAllocator::m_pool
ArenaHeapAllocator m_pool
The underlying allocator.
Definition: ArenaHeapSTLAllocator.h:342
SG::ArenaHeapSTLAllocator::operator=
ArenaHeapSTLAllocator & operator=(ArenaHeapSTLAllocator &&a)
Move assignment.
SG::ArenaHeapSTLAllocator::difference_type
ptrdiff_t difference_type
Definition: ArenaHeapSTLAllocator.h:103
SG::ArenaHeapSTLAllocator::propagate_on_container_swap
std::true_type propagate_on_container_swap
Definition: ArenaHeapSTLAllocator.h:110
SG::ArenaHeapSTLAllocator< T, T >::m_poolptr
const ArenaBlockAllocatorBase * m_poolptr
Point at an underlying allocator from a different specialization.
Definition: ArenaHeapSTLAllocator.h:455
SG::ArenaHeapSTLAllocator::value_type
T value_type
Definition: ArenaHeapSTLAllocator.h:101
SG::ArenaHeapSTLAllocator::destroy
void destroy(pointer p)
Call the T destructor.
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::ArenaHeapSTLAllocator::stats
ArenaAllocatorBase::Stats stats() const
Return the statistics block for this allocator.
SG::ArenaHeapSTLAllocator::reset
void reset()
Free all allocated elements.
SG::ArenaHeapAllocator::initParams
Helper to initialize a parameters structure.
Definition: ArenaHeapAllocator.h:88
SG::ArenaHeapSTLAllocator::protect
void protect()
Write-protect the memory managed by this allocator.
SG::ArenaHeapSTLAllocator< T, T >::get_allocator
static ArenaNonConstHeapSTLAllocator< T > get_allocator(CONT &c)
Return an allocator supporting non-const methods from a non-const container reference.
SG::ArenaHeapSTLAllocator::poolptr
const ArenaBlockAllocatorBase * poolptr() const
Return a pointer to the underlying allocator (may be 0).
SG::ArenaHeapSTLAllocator< T, T >::ArenaHeapSTLAllocator
ArenaHeapSTLAllocator(size_t nblock=1000, const std::string &name="")
Default constructor.
SG::ArenaHeapSTLAllocator< T, T >::m_name
std::string m_name
Saved allocator name.
Definition: ArenaHeapSTLAllocator.h:452
SG::ArenaHeapSTLAllocator::const
size_type n const
Definition: ArenaHeapSTLAllocator.h:226
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SG::ArenaHeapSTLAllocator::propagate_on_container_copy_assignment
std::false_type propagate_on_container_copy_assignment
When we assign to a container, the target should retain its allocator.
Definition: ArenaHeapSTLAllocator.h:106
SG::ArenaHeapSTLAllocator::ArenaHeapSTLAllocator
ArenaHeapSTLAllocator(const ArenaHeapSTLAllocator &a)
Copy constructor.
checker_macros.h
Define macros for attributes used to control the static checker.
SG::ArenaHeapSTLAllocator::ArenaHeapSTLAllocator
ArenaHeapSTLAllocator(const ArenaHeapSTLAllocator< U, V > &a)
Constructor from another ArenaHeapSTLAllocator.
SG::ArenaNonConstHeapSTLAllocator::unprotect
void unprotect()
Write-enable the memory managed by this allocator.
SG::ArenaHeapSTLAllocator< T, T >::poolptr
const ArenaBlockAllocatorBase * poolptr() const
Return a pointer to the underlying allocator (may be 0).
SG::ArenaAllocatorBase::Params
Allocator parameters.
Definition: ArenaAllocatorBase.h:150
python.compressB64.c
def c
Definition: compressB64.py:93
SG::ArenaHeapSTLAllocator_initParams::Base
ArenaHeapAllocator::initParams< T, false, true, true > Base
We take defaults from this.
Definition: ArenaHeapSTLAllocator.h:65
SG::ArenaHeapSTLAllocator::unprotect
void unprotect()
Write-enable the memory managed by this allocator.
SG::ArenaHeapSTLAllocator::max_size
size_type max_size() const
Return the maximum number of objects we can allocate at once.
ArenaHeapAllocator.h
Heap-based allocator. See Arena.h for an overview of the arena-based memory allocators.
SG::ArenaNonConstHeapSTLAllocator::m_poolptr_nc
ArenaBlockAllocatorBase * m_poolptr_nc
Non-const pointer to the underlying allocator.
Definition: ArenaHeapSTLAllocator.h:542
SG::ArenaHeapSTLAllocator::deallocate
deallocate(p_nc, n)
SG::ArenaHeapSTLAllocator::swap
void swap(ArenaHeapSTLAllocator &a)
Swap.
SG::ArenaHeapSTLAllocator::nblock
size_t nblock() const
Return the hinted number of objects allocated per block.