ATLAS Offline Software
ArenaHeapAllocator.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 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id: ArenaHeapAllocator.h 470529 2011-11-24 23:54:22Z ssnyder $
8 
18 #ifndef ATLALLOCATORS_ARENAHEAPALLOCATOR_H
19 #define ATLALLOCATORS_ARENAHEAPALLOCATOR_H
20 
21 
23 #include <cstdlib>
24 
25 
26 namespace SG {
27 
28 
29 class ArenaBlock;
30 
31 
64 {
65 public:
82  template <typename T,
83  bool clear = false,
84  bool no_ctor = false,
85  bool no_dtor = false>
86  struct initParams
87  : public ArenaAllocatorBase::initParams<T, clear, no_ctor, no_dtor>
88  {
89  // Short name for our base class.
91 
92 
100  initParams (size_t nblock = 1000, const std::string& name = "");
101 
104 
106  // Note: gcc 3.2.3 doesn't allow defining this out-of-line.
107  operator ArenaAllocatorBase::Params() const { return params(); }
108  };
109 
110 
116  ArenaHeapAllocator (const Params& params);
117 
118 
122  virtual ~ArenaHeapAllocator();
123 
124 
128 
129 
134 
135 
140 
141 
145  void swap (ArenaHeapAllocator& other);
146 
147 
154 
155 
163  void free (pointer p);
164 
165 
174  virtual void reset() override;
175 
176 
185  // cppcheck-suppress virtualCallInConstructor ; false positive
186  virtual void erase() override final;
187 
188 
189  // These are just placeholders --- the iterators are not implemented.
190  typedef void iterator;
191  typedef void const_iterator;
192 
193 
194 private:
198  void slowClear();
199 
200 
204  pointer refill();
205 
206 
212 
215 };
216 
217 
218 } // namespace SG
219 
220 
221 #include "AthAllocators/ArenaHeapAllocator.icc"
222 
223 
224 #endif // not ATLALLOCATORS_ARENAHEAPALLOCATOR_H
SG::ArenaBlockAllocatorBase::params
const Params & params() const
Return this Allocator's parameters.
Definition: ArenaBlockAllocatorBase.cxx:224
SG::ArenaHeapAllocator::operator=
ArenaHeapAllocator & operator=(const ArenaHeapAllocator &)=delete
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaHeapAllocator::free
void free(pointer p)
Free an element.
SG::ArenaHeapAllocator::ArenaHeapAllocator
ArenaHeapAllocator(const ArenaHeapAllocator &)=delete
Don't allow copy construction or assignment.
SG::ArenaHeapAllocator
Heap-based allocator.
Definition: ArenaHeapAllocator.h:64
SG::ArenaBlockAllocatorBase::name
virtual const std::string & name() const override
Return the name of this allocator.
Definition: ArenaBlockAllocatorBase.cxx:214
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::ArenaHeapAllocator::initParams::initParams
initParams(size_t nblock=1000, const std::string &name="")
Constructor.
SG::ArenaHeapAllocator::slowClear
void slowClear()
Call clear() for all allocated elements.
Definition: ArenaHeapAllocator.cxx:164
SG::ArenaHeapAllocator::const_iterator
void const_iterator
Definition: ArenaHeapAllocator.h:191
ArenaBlockAllocatorBase.h
Common functionality for block-oriented allocators.
SG::ArenaHeapAllocator::erase
virtual void erase() override final
Free all allocated elements and release memory back to the system.
Definition: ArenaHeapAllocator.cxx:129
SG::ArenaHeapAllocator::swap
void swap(ArenaHeapAllocator &other)
Swap.
Definition: ArenaHeapAllocator.cxx:78
SG::ArenaHeapAllocator::reset
virtual void reset() override
Free all allocated elements.
Definition: ArenaHeapAllocator.cxx:95
SG::ArenaBlockAllocatorBase
Common functionality for block-oriented allocators.
Definition: ArenaBlockAllocatorBase.h:35
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
SG::ArenaHeapAllocator::initParams::Base
ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor > Base
Definition: ArenaHeapAllocator.h:90
SG::ArenaHeapAllocator::m_freeptr
pointer m_freeptr
Pointer to the next free element.
Definition: ArenaHeapAllocator.h:214
SG::ArenaHeapAllocator::iterator
void iterator
Definition: ArenaHeapAllocator.h:190
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
SG::ArenaHeapAllocator::initParams
Helper to initialize a parameters structure.
Definition: ArenaHeapAllocator.h:88
SG::ArenaAllocatorBase::initParams
Helper to initialize a parameters structure.
Definition: ArenaAllocatorBase.h:316
SG::ArenaAllocatorBase::pointer
char * pointer
Type for pointers to elements.
Definition: ArenaAllocatorBase.h:137
SG::ArenaHeapAllocator::refill
pointer refill()
Add more free elements to the pool, and allocate a new element.
Definition: ArenaHeapAllocator.cxx:139
SG::ArenaHeapAllocator::ArenaHeapAllocator
ArenaHeapAllocator(const Params &params)
Constructor.
Definition: ArenaHeapAllocator.cxx:27
SG::ArenaAllocatorBase::Params
Allocator parameters.
Definition: ArenaAllocatorBase.h:150
SG::ArenaHeapAllocator::link
pointer & link(pointer p) const
Return a reference to the link for an element.
SG::ArenaHeapAllocator::initParams::params
ArenaAllocatorBase::Params params() const
Return an initialized parameters structure.
SG::ArenaHeapAllocator::allocate
pointer allocate()
Allocate a new element.
SG::ArenaHeapAllocator::~ArenaHeapAllocator
virtual ~ArenaHeapAllocator()
Destructor.
Definition: ArenaHeapAllocator.cxx:39