ATLAS Offline Software
Loading...
Searching...
No Matches
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
16
17
18#ifndef ATLALLOCATORS_ARENAHEAPALLOCATOR_H
19#define ATLALLOCATORS_ARENAHEAPALLOCATOR_H
20
21
23#include <cstdlib>
24
25
26namespace SG {
27
28
29class ArenaBlock;
30
31
64{
65public:
82 template <typename T,
83 bool clear = false,
84 bool no_ctor = false,
85 bool no_dtor = false>
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 virtual void erase() override final;
186
187
188 // These are just placeholders --- the iterators are not implemented.
189 typedef void iterator;
190 typedef void const_iterator;
191
192
193private:
197 void slowClear();
198
199
203 pointer refill();
204
205
211
214};
215
216
217} // namespace SG
218
219
220#include "AthAllocators/ArenaHeapAllocator.icc"
221
222
223#endif // not ATLALLOCATORS_ARENAHEAPALLOCATOR_H
Common functionality for block-oriented allocators.
char * pointer
Type for pointers to elements.
const Params & params() const
Return this Allocator's parameters.
ArenaBlockAllocatorBase(const Params &params)
Constructor.
virtual const std::string & name() const override
Return the name of this allocator.
A large memory block that gets carved into smaller uniform elements.
Definition ArenaBlock.h:43
ArenaHeapAllocator & operator=(const ArenaHeapAllocator &)=delete
virtual ~ArenaHeapAllocator()
Destructor.
void swap(ArenaHeapAllocator &other)
Swap.
pointer refill()
Add more free elements to the pool, and allocate a new element.
ArenaHeapAllocator(const ArenaHeapAllocator &)=delete
Don't allow copy construction or assignment.
void slowClear()
Call clear() for all allocated elements.
pointer m_freeptr
Pointer to the next free element.
pointer & link(pointer p) const
Return a reference to the link for an element.
void free(pointer p)
Free an element.
pointer allocate()
Allocate a new element.
virtual void erase() override final
Free all allocated elements and release memory back to the system.
virtual void reset() override
Free all allocated elements.
ArenaHeapAllocator(const Params &params)
Constructor.
Forward declaration.
Helper to initialize a parameters structure.
ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor > Base
initParams(size_t nblock=1000, const std::string &name="")
Constructor.
ArenaAllocatorBase::Params params() const
Return an initialized parameters structure.
#define private