ATLAS Offline Software
ArenaPoolAllocator.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-2022 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef ATHALLOCATORS_ARENAPOOLALLOCATOR_H
14 #define ATHALLOCATORS_ARENAPOOLALLOCATOR_H
15 
16 
18 #include "boost/iterator/iterator_adaptor.hpp"
19 #include <cstdlib>
20 
21 
22 namespace SG {
23 
24 
25 class ArenaBlock;
26 
27 
40 {
41 public:
42  // Needed forward declaration.
43  class const_iterator;
44 
53  class iterator
54  : public boost::iterator_adaptor<
55  iterator,
56  pointer,
57  boost::use_default,
58  boost::forward_traversal_tag>
59  {
60  public:
65 
66 
73 
74 
75  // To allow initializing a @c const_iterator from an @c iterator.
76  friend class const_iterator;
77 
78 
79  private:
82 
83  // Required by @c iterator_adaptor.
85 
87  void increment();
88  };
89 
90 
100  : public boost::iterator_adaptor<
101  const_iterator,
102  const_pointer,
103  boost::use_default,
104  boost::forward_traversal_tag>
105  {
106  public:
111 
112 
119 
120 
126 
127 
128  private:
131 
132  // Required by @c iterator_adaptor.
134 
136  void increment();
137  };
138 
139 
146 
147 
151  virtual ~ArenaPoolAllocator();
152 
153 
157 
158 
163 
164 
169 
170 
174  void swap (ArenaPoolAllocator& other);
175 
176 
183 
184 
193  virtual void reset() override;
194 
195 
204  // cppcheck-suppress virtualCallInConstructor ; false positive
205  virtual void erase() override final;
206 
207 
215  void resetTo (pointer p);
216 
217 
224  iterator begin();
225 
226 
234 
235 
239  iterator end();
240 
241 
246 
247 
248 private:
252  void refill();
253 
254 
259  void clearBlock();
260 
261 
264 
267 };
268 
269 
270 } // namespace SG
271 
272 
273 #include "AthAllocators/ArenaPoolAllocator.icc"
274 
275 
276 #endif // not ATHALLOCATORS_ARENAPOOLALLOCATOR_H
SG::ArenaBlockAllocatorBase::params
const Params & params() const
Return this Allocator's parameters.
Definition: ArenaBlockAllocatorBase.cxx:224
SG::ArenaPoolAllocator::refill
void refill()
Add more free elements to the pool.
Definition: ArenaPoolAllocator.cxx:304
SG::ArenaPoolAllocator
Pool-based allocator.
Definition: ArenaPoolAllocator.h:40
SG::ArenaPoolAllocator::resetTo
void resetTo(pointer p)
Reset pool back to a previous state.
Definition: ArenaPoolAllocator.cxx:208
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaPoolAllocator::const_iterator::increment
void increment()
Move the iterator forward.
Definition: ArenaPoolAllocator.cxx:83
SG::ArenaPoolAllocator::const_iterator::const_iterator
const_iterator()
Default constructor.
skel.it
it
Definition: skel.GENtoEVGEN.py:423
SG::ArenaPoolAllocator::const_iterator::m_block
const ArenaBlock * m_block
Block containing the current element.
Definition: ArenaPoolAllocator.h:130
SG::ArenaPoolAllocator::iterator::iterator_core_access
friend class boost::iterator_core_access
Definition: ArenaPoolAllocator.h:84
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::ArenaPoolAllocator::swap
void swap(ArenaPoolAllocator &other)
Swap.
Definition: ArenaPoolAllocator.cxx:151
SG::ArenaPoolAllocator::iterator::iterator
iterator(pointer p, ArenaBlock *block)
Constructor.
SG::ArenaPoolAllocator::operator=
ArenaPoolAllocator & operator=(const ArenaPoolAllocator &)=delete
SG::ArenaPoolAllocator::m_end
pointer m_end
One past the last available element in the current block, of null.
Definition: ArenaPoolAllocator.h:266
SG::ArenaPoolAllocator::clearBlock
void clearBlock()
Reset all elements in the topmost block, and move the block to the free list.
Definition: ArenaPoolAllocator.cxx:319
SG::ArenaPoolAllocator::m_ptr
pointer m_ptr
Pointer to the next free element to allocate, or null.
Definition: ArenaPoolAllocator.h:263
SG::ArenaPoolAllocator::ArenaPoolAllocator
ArenaPoolAllocator(const ArenaPoolAllocator &)=delete
Don't allow copy construction or assignment.
SG::ArenaPoolAllocator::const_iterator::iterator_core_access
friend class boost::iterator_core_access
Definition: ArenaPoolAllocator.h:133
ArenaBlockAllocatorBase.h
Common functionality for block-oriented allocators.
SG::ArenaPoolAllocator::iterator::iterator
iterator()
Default constructor.
SG::ArenaBlockAllocatorBase
Common functionality for block-oriented allocators.
Definition: ArenaBlockAllocatorBase.h:35
SG::ArenaPoolAllocator::iterator
Non-const iterator for the pool.
Definition: ArenaPoolAllocator.h:59
SG::ArenaPoolAllocator::iterator::m_block
ArenaBlock * m_block
Block containing the current element.
Definition: ArenaPoolAllocator.h:81
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
SG::ArenaBlock
A large memory block that gets carved into smaller uniform elements.
Definition: ArenaBlock.h:43
SG::ArenaPoolAllocator::begin
iterator begin()
Starting pool iterator.
Definition: ArenaPoolAllocator.cxx:261
SG::ArenaPoolAllocator::reset
virtual void reset() override
Free all allocated elements.
Definition: ArenaPoolAllocator.cxx:169
SG::ArenaPoolAllocator::const_iterator::const_iterator
const_iterator(const iterator &it)
Constructor from iterator.
SG::ArenaPoolAllocator::iterator::increment
void increment()
Move the iterator forward.
Definition: ArenaPoolAllocator.cxx:73
SG::ArenaPoolAllocator::erase
virtual void erase() override final
Free all allocated elements and release memory back to the system.
Definition: ArenaPoolAllocator.cxx:191
SG::ArenaPoolAllocator::ArenaPoolAllocator
ArenaPoolAllocator(const Params &params)
Constructor.
Definition: ArenaPoolAllocator.cxx:96
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::ArenaPoolAllocator::~ArenaPoolAllocator
virtual ~ArenaPoolAllocator()
Destructor.
Definition: ArenaPoolAllocator.cxx:107
SG::ArenaAllocatorBase::pointer
char * pointer
Type for pointers to elements.
Definition: ArenaAllocatorBase.h:137
SG::ArenaPoolAllocator::allocate
pointer allocate()
Allocate a new element.
SG::ArenaPoolAllocator::end
iterator end()
Ending pool iterator.
Definition: ArenaPoolAllocator.cxx:284
SG::ArenaPoolAllocator::const_iterator
Const iterator for the pool.
Definition: ArenaPoolAllocator.h:105
SG::ArenaPoolAllocator::const_iterator::const_iterator
const_iterator(pointer p, const ArenaBlock *block)
Constructor.
SG::ArenaAllocatorBase::Params
Allocator parameters.
Definition: ArenaAllocatorBase.h:150