Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataPool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHALLOCATORS_DATAPOOL_H
6 #define ATHALLOCATORS_DATAPOOL_H
7 
39 #include <string>
40 #include "boost/iterator/iterator_adaptor.hpp"
41 
42 
43 namespace SG {
44 
45 
50 template <class VALUE>
52 {
53 public:
54  static void clear (VALUE*) {}
55 };
56 
57 
58 } // namespace SG
59 
60 
61 template <typename VALUE, typename CLEAR = SG::DataPoolNullClear<VALUE> >
62 class DataPool
63 {
64 private:
67 
68 public:
69  typedef typename handle_t::pointer pointer;
70  typedef size_t size_type;
71 
72  class const_iterator;
73 
74  class iterator
75  : public boost::iterator_adaptor<
76  iterator,
77  typename handle_t::iterator,
78  VALUE *,
79  boost::forward_traversal_tag,
80  VALUE *>
81  {
82  public:
83  iterator (const typename handle_t::iterator& it)
84  : iterator::iterator_adaptor_ (it)
85  {
86  }
87 
88  friend class const_iterator;
89 
90  private:
92 
94  { return &*this->base_reference(); }
95  };
96 
98  : public boost::iterator_adaptor<
99  const_iterator,
100  typename handle_t::const_iterator,
101  VALUE const *,
102  boost::forward_traversal_tag,
103  VALUE const *>
104  {
105  public:
107  : const_iterator::iterator_adaptor_ (it)
108  {
109  }
110 
112  : const_iterator::iterator_adaptor_ (it.base_reference())
113  {
114  }
115 
116  private:
118 
120  { return &*this->base_reference(); }
121  };
122 
123 
127 
129 
130  DataPool(const EventContext& ctx,
131  size_type n = 0);
132 
134  size_type n = 0);
135 
137 
139  void reset();
140 
142  void erase();
143 
156  void reserve(unsigned int size);
157 
168  void prepareToAdd(unsigned int size);
169 
171  unsigned int capacity();
172 
174  unsigned int allocated();
175 
179 
184 
190 
192  static const std::string& typeName();
193 
194 //-----------------------------------------------------------//
195 
196  private:
197 
199 
200  const static typename alloc_t::Params s_params;
201 
203  static constexpr size_t s_minRefCount = 1024;
204 
205  static typename alloc_t::Params initParams();
207 };
208 
209 
211 
212 #endif
213 
214 
SG::ArenaCachingHandle< VALUE, alloc_t >::iterator
Base::iterator iterator
Iterators over elements.
Definition: ArenaCachingHandle.h:88
DataPool::const_iterator::const_iterator
const_iterator(const typename handle_t::const_iterator &it)
Definition: DataPool.h:106
DataPool::pointer
handle_t::pointer pointer
Definition: DataPool.h:69
SG::ArenaCachingHandle< VALUE, alloc_t >
SG::ArenaPoolAllocator
Pool-based allocator.
Definition: ArenaPoolAllocator.h:40
DataPool::m_handle
handle_t m_handle
Definition: DataPool.h:198
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
DataPool::DataPool
DataPool(size_type n=0)
Constructors:
skel.it
it
Definition: skel.GENtoEVGEN.py:407
SG::DataPoolNullClear::clear
static void clear(VALUE *)
Definition: DataPool.h:54
DataPool::iterator::iterator_core_access
friend class boost::iterator_core_access
Definition: DataPool.h:91
DataPool::reserve
void reserve(unsigned int size)
Set the desired capacity.
DataPool::s_minRefCount
static constexpr size_t s_minRefCount
minimum number of elements in pool
Definition: DataPool.h:203
DataPool::begin
const_iterator begin() const
DataPool.icc
DataPool::reset
void reset()
release all elements in the pool.
DataPool::const_iterator::const_iterator
const_iterator(const iterator &it)
Definition: DataPool.h:111
DataPool::DataPool
DataPool(SG::Arena *arena, size_type n=0)
DataPool::end
const_iterator end() const
SG::ArenaCachingHandle< VALUE, alloc_t >::pointer
VALUE * pointer
Pointer to an element.
Definition: ArenaCachingHandle.h:84
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DataPool::nextElementPtr
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
DataPool::capacity
unsigned int capacity()
return capacity of pool OK
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DataPool::prepareToAdd
void prepareToAdd(unsigned int size)
Prepare to add cached elements.
DataPool::callClear
static void callClear(SG::ArenaAllocatorBase::pointer p)
beamspotman.n
n
Definition: beamspotman.py:731
SG::Arena
Collection of memory allocators with a common lifetime,.
Definition: Arena.h:238
VALUE
#define VALUE(TESTED)
Definition: expect.h:59
DataPool::iterator::iterator
iterator(const typename handle_t::iterator &it)
Definition: DataPool.h:83
DataPool::iterator::dereference
iterator::reference dereference() const
Definition: DataPool.h:93
DataPool::erase
void erase()
free all memory in the pool.
DataPool::const_iterator::dereference
const_iterator::reference dereference() const
Definition: DataPool.h:119
DataPool::end
iterator end()
the end() method will allow looping over only valid elements and not over ALL elements of the pool
DataPool::size_type
size_t size_type
Definition: DataPool.h:70
DataPool::handle_t
SG::ArenaCachingHandle< VALUE, alloc_t > handle_t
Definition: DataPool.h:66
ArenaCachingHandle.h
User interface for allocating memory that caches constructed objects. See Arena.h for an overview of ...
ArenaPoolAllocator.h
Pool-based allocator. See Arena.h for an overview of the arena-based memory allocators.
DataPool::typeName
static const std::string & typeName()
typename of pool
DataPool::alloc_t
SG::ArenaPoolAllocator alloc_t
Definition: DataPool.h:65
DataPool::DataPool
DataPool(const EventContext &ctx, size_type n=0)
DataPool::iterator
Definition: DataPool.h:81
SG::ArenaCachingHandle< VALUE, alloc_t >::const_iterator
Base::const_iterator const_iterator
Definition: ArenaCachingHandle.h:89
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:63
SG::DataPoolNullClear
Null cleanup functional — does no actual cleanup.
Definition: DataPool.h:52
DataPool::const_iterator::iterator_core_access
friend class boost::iterator_core_access
Definition: DataPool.h:117
DataPool::begin
iterator begin()
begin iterators over pool
SG::ArenaAllocatorBase::pointer
char * pointer
Type for pointers to elements.
Definition: ArenaAllocatorBase.h:137
DataPool::allocated
unsigned int allocated()
return size already allocated OK
DataPool::initParams
static alloc_t::Params initParams()
SG::ArenaAllocatorBase::Params
Allocator parameters.
Definition: ArenaAllocatorBase.h:150
DataPool::const_iterator
Definition: DataPool.h:104
DataPool::s_params
static const alloc_t::Params s_params
Definition: DataPool.h:200