Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ArenaSharedHeapSTLAllocator.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 */
59 #ifndef ATLALLOCATORS_ARENASHAREDHEAPSTLALLOCATOR_H
60 #define ATLALLOCATORS_ARENASHAREDHEAPSTLALLOCATOR_H
61 
62 
66 #include <string>
67 #include <vector>
68 
69 
70 namespace SG {
71 
73 template <class T>
75 
76 
90 {
91 public:
98  ArenaSharedHeapSTLHeader (const void* owner, int nblock);
99 
100 
107 
108 
116  void maybe_delete (const void* a);
117 
118 
123 
124 
128  template <class T>
129  static std::string get_name();
130 
131 
135  template <class T>
137 
138 
146  void update_owner (const void* old_owner, const void* new_owner);
147 
148 
153  void report (std::ostream& os) const;
154 
155 
162  void protect();
163 
164 
171  void unprotect();
172 
173 
174 private:
178  template <class T>
179  static size_t get_index();
180 
182  const void* m_owner;
183 
185  size_t m_nblock;
186 
188  std::vector<ArenaHeapAllocator*> m_allocators;
189 };
190 
191 
192 
193 
200 template <class T>
202 {
203 public:
206  template <class U> friend class ArenaSharedHeapSTLAllocator;
207 
209  typedef T* pointer;
210  typedef const T* const_pointer;
211  typedef T& reference;
212  typedef const T& const_reference;
213  typedef T value_type;
214  typedef size_t size_type;
215  typedef ptrdiff_t difference_type;
216 
218  typedef std::false_type propagate_on_container_copy_assignment;
219 
222  typedef std::true_type propagate_on_container_swap;
223 
224 
226  template <class U> struct rebind {
228  };
229 
230 
237 
238 
246 
247 
250 
251 
258  template <class U>
260 
261 
262  // We don't bother to supply a more general constructor --- shouldn't
263  // be needed.
264 
265 
270 
271 
281 
282 
289 
290 
295 
296 
305 
306 
315 
316 
319  template <bool = true>
320  requires (!std::same_as<reference,const_reference>)
322  address (const_reference x) const { return &x; }
323 
324 
330  pointer allocate (size_type n, const void* hint = 0);
331 
332 
338  template <bool = true>
339  requires (!std::same_as<reference,const_reference>)
340  void
342  {
343  pointer p_nc ATLAS_THREAD_SAFE = const_cast<pointer>(p);
344  deallocate (p_nc, n);
345  }
346 
347 
353  size_type max_size() const throw();
354 
355 
361  template <class... Args>
362  void construct (pointer p, Args&&... args);
363 
364 
369  void destroy (pointer p);
370 
371 
375  size_t nblock() const;
376 
377 
381  const std::string& name() const;
382 
383 
392  void reset();
393 
394 
403  void erase();
404 
405 
423  void reserve (size_t size);
424 
425 
430 
431 
437 
438 
443 
444 
449 
450 
455  void report (std::ostream& os) const;
456 
457 
464  void protect();
465 
466 
473  void unprotect();
474 
475 
476 private:
479 };
480 
481 
482 template <class T>
484 {
485  a.swap (b);
486 }
487 
488 
497 template <class T>
499 
500 
501 } // namespace SG
502 
503 
505 
506 
507 #endif // not ATLALLOCATORS_ARENASHAREDHEAPSTLALLOCATOR_H
SG::ArenaSharedHeapSTLAllocator::ArenaSharedHeapSTLAllocator
ArenaSharedHeapSTLAllocator(ArenaSharedHeapSTLAllocator &&a)=default
Move constructor is the same as the copy constructor.
SG::ArenaSharedHeapSTLAllocator::allocate
pointer allocate(size_type n, const void *hint=0)
Allocate new objects.
SG::ArenaSharedHeapSTLHeader::m_owner
const void * m_owner
Address of the allocator that created this header.
Definition: ArenaSharedHeapSTLAllocator.h:182
SG::ArenaSharedHeapSTLHeader::~ArenaSharedHeapSTLHeader
~ArenaSharedHeapSTLHeader()
Destructor.
Definition: ArenaSharedHeapSTLAllocator.cxx:39
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaSharedHeapSTLAllocator::rebind::other
ArenaSharedHeapSTLAllocator< U > other
Definition: ArenaSharedHeapSTLAllocator.h:227
SG::ArenaSharedHeapSTLAllocator::operator!=
bool operator!=(const ArenaSharedHeapSTLAllocator &other) const
Inequality test.
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:45
SG::ArenaSharedHeapSTLHeader::protect
void protect()
Write-protect the memory managed by these allocators.
Definition: ArenaSharedHeapSTLAllocator.cxx:82
SG::ArenaSharedHeapSTLAllocator::~ArenaSharedHeapSTLAllocator
~ArenaSharedHeapSTLAllocator()
Destructor.
SG::ArenaSharedHeapSTLAllocator::reserve
void reserve(size_t size)
Set the total number of elements cached by the allocator.
SG::ArenaHeapAllocator
Heap-based allocator.
Definition: ArenaHeapAllocator.h:64
SG::ArenaSharedHeapSTLHeader
Common header class for ArenaSharedHeapSTLAllocator.
Definition: ArenaSharedHeapSTLAllocator.h:90
SG::ArenaSharedHeapSTLHeader::get_name
static std::string get_name()
Return the name to use for an allocator for type T.
taskman.template
dictionary template
Definition: taskman.py:317
SG::ArenaSharedHeapSTLAllocator::construct
void construct(pointer p, Args &&... args)
Call the T constructor.
SG::ArenaSharedHeapSTLAllocator::destroy
void destroy(pointer p)
Call the T destructor.
SG::maybeUnprotect
void maybeUnprotect(ArenaHeapSTLAllocator< T, VETO > &a)
Hook for unprotecting an arena.
SG::ArenaSharedHeapSTLHeader::get_index
static size_t get_index()
Return the allocator index to use for type T.
Args
Definition: test_lwtnn_fastgraph.cxx:12
SG::ArenaSharedHeapSTLHeader::get_pool
ArenaHeapAllocator * get_pool()
Return the heap allocator for type T.
SG::ArenaSharedHeapSTLAllocator::deallocate
deallocate(p_nc, n)
SG::ArenaSharedHeapSTLAllocator::reset
void reset()
Free all allocated elements.
x
#define x
SG::ArenaSharedHeapSTLAllocator::ArenaSharedHeapSTLAllocator
ArenaSharedHeapSTLAllocator(size_t nblock=1000)
Default constructor.
SG::ArenaSharedHeapSTLAllocator::difference_type
ptrdiff_t difference_type
Definition: ArenaSharedHeapSTLAllocator.h:215
SG::ArenaSharedHeapSTLAllocator::const
size_type n const
Definition: ArenaSharedHeapSTLAllocator.h:342
SG::ArenaSharedHeapSTLAllocator::name
const std::string & name() const
Return the name of this allocator.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::ArenaSharedHeapSTLAllocator::poolptr
ArenaHeapAllocator * poolptr()
Return a pointer to the underlying allocator.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::ArenaSharedHeapSTLAllocator::max_size
size_type max_size() const
Return the maximum number of objects we can allocate at once.
SG::ArenaAllocatorBase::Stats
Statistics for an allocator.
Definition: ArenaAllocatorBase.h:188
SG::ArenaSharedHeapSTLAllocator::size_type
size_t size_type
Definition: ArenaSharedHeapSTLAllocator.h:214
SG::ArenaSharedHeapSTLAllocator::protect
void protect()
Write-protect the memory managed by these allocators.
SG::ArenaSharedHeapSTLAllocator::operator==
bool operator==(const ArenaSharedHeapSTLAllocator &other) const
Equality test.
beamspotman.n
n
Definition: beamspotman.py:731
SG::ArenaSharedHeapSTLAllocator::requires
requires(!std::same_as< reference, const_reference >) const _pointer address(const_reference x) const
Definition: ArenaSharedHeapSTLAllocator.h:320
SG::ArenaSharedHeapSTLAllocator::propagate_on_container_move_assignment
std::true_type propagate_on_container_move_assignment
Move allocators on move/swap.
Definition: ArenaSharedHeapSTLAllocator.h:221
SG::ArenaAllocatorBase
Common base class for arena allocator classes.
Definition: ArenaAllocatorBase.h:134
SG::ArenaSharedHeapSTLAllocator::erase
void erase()
Free all allocated elements and release memory back to the system.
SG::ArenaSharedHeapSTLAllocator::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: ArenaSharedHeapSTLAllocator.h:218
SG::ArenaSharedHeapSTLAllocator::address
pointer address(reference x) const
Convert a reference to an address.
SG::ArenaSharedHeapSTLAllocator::rebind
Standard STL allocator rebinder.
Definition: ArenaSharedHeapSTLAllocator.h:226
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ArenaSharedHeapSTLAllocator::ArenaSharedHeapSTLAllocator
ArenaSharedHeapSTLAllocator(const ArenaSharedHeapSTLAllocator< U > &a)
Constructor from another ArenaSharedHeapSTLAllocator.
SG::ArenaSharedHeapSTLAllocator::operator=
ArenaSharedHeapSTLAllocator & operator=(const ArenaSharedHeapSTLAllocator &a)
Assignment.
SG::ArenaSharedHeapSTLAllocator::const_pointer
const T * const_pointer
Definition: ArenaSharedHeapSTLAllocator.h:210
SG::ArenaSharedHeapSTLAllocator::reference
T & reference
Definition: ArenaSharedHeapSTLAllocator.h:211
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SG::ArenaSharedHeapSTLHeader::maybe_delete
void maybe_delete(const void *a)
Call this when an allocator is being deleted.
SG::ArenaSharedHeapSTLHeader::m_allocators
std::vector< ArenaHeapAllocator * > m_allocators
List of allocators.
Definition: ArenaSharedHeapSTLAllocator.h:188
SG::ArenaSharedHeapSTLAllocator::nblock
size_t nblock() const
Return the hinted number of objects allocated per block.
ArenaSharedHeapSTLAllocator.icc
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::ArenaSharedHeapSTLHeader::m_nblock
size_t m_nblock
Saved value for nblock parameter.
Definition: ArenaSharedHeapSTLAllocator.h:185
SG::ArenaSharedHeapSTLAllocator::report
void report(std::ostream &os) const
Generate printable report for all contained allocators.
SG::ArenaSharedHeapSTLAllocator::ArenaSharedHeapSTLAllocator
ArenaSharedHeapSTLAllocator(const ArenaSharedHeapSTLAllocator &a)
Copy constructor.
SG::ArenaSharedHeapSTLHeader::ArenaSharedHeapSTLHeader
ArenaSharedHeapSTLHeader(const void *owner, int nblock)
Constructor.
Definition: ArenaSharedHeapSTLAllocator.cxx:26
SG::ArenaSharedHeapSTLAllocator::propagate_on_container_swap
std::true_type propagate_on_container_swap
Definition: ArenaSharedHeapSTLAllocator.h:222
SG::ArenaSharedHeapSTLAllocator::stats
ArenaAllocatorBase::Stats stats() const
Return the statistics block for this allocator.
SG::ArenaSharedHeapSTLAllocator::m_pool
ArenaHeapAllocator * m_pool
Definition: ArenaSharedHeapSTLAllocator.h:478
SG::ArenaSharedHeapSTLAllocator::swap
void swap(ArenaSharedHeapSTLAllocator &a)
Swap.
SG::ArenaSharedHeapSTLAllocator::requires
requires(!std::same_as< reference, const_reference >) void deallocate(const_pointer p
SG::ArenaSharedHeapSTLAllocator::unprotect
void unprotect()
Write-enable the memory managed by these allocators.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SG::ArenaSharedHeapSTLAllocator::value_type
T value_type
Definition: ArenaSharedHeapSTLAllocator.h:213
SG::ArenaSharedHeapSTLAllocator::m_header
ArenaSharedHeapSTLHeader * m_header
Definition: ArenaSharedHeapSTLAllocator.h:477
ArenaAllocatorRegistry.h
Registry of allocator factories. See Arena.h for an overview of the arena-based memory allocators.
SG::ArenaSharedHeapSTLAllocator::deallocate
void deallocate(pointer, size_type n)
Deallocate objects.
ArenaHeapSTLAllocator.h
STL-style allocator wrapper for ArenaHeapAllocator.
SG::ArenaSharedHeapSTLAllocator::totstats
ArenaAllocatorBase::Stats totstats() const
Return the statistics blocks summed up over all allocators using this pool.
SG::ArenaSharedHeapSTLHeader::update_owner
void update_owner(const void *old_owner, const void *new_owner)
Update the owner of this object.
SG::ArenaSharedHeapSTLHeader::unprotect
void unprotect()
Write-enable the memory managed by these allocators.
Definition: ArenaSharedHeapSTLAllocator.cxx:98
ArenaHeapAllocator.h
Heap-based allocator. See Arena.h for an overview of the arena-based memory allocators.
SG::ArenaSharedHeapSTLHeader::report
void report(std::ostream &os) const
Generate printable report for all contained allocators.
Definition: ArenaSharedHeapSTLAllocator.cxx:67
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
SG::ArenaSharedHeapSTLHeader::totstats
ArenaAllocatorBase::Stats totstats() const
Return allocator statistics summed over all our owned allocators.
Definition: ArenaSharedHeapSTLAllocator.cxx:51
SG::ArenaSharedHeapSTLAllocator
Forward declaration.
Definition: ArenaSharedHeapSTLAllocator.h:74
SG::ArenaSharedHeapSTLAllocator::pointer
T * pointer
Standard STL allocator typedefs.
Definition: ArenaSharedHeapSTLAllocator.h:209
SG::ArenaSharedHeapSTLAllocator::const_reference
const T & const_reference
Definition: ArenaSharedHeapSTLAllocator.h:212