Peano
Loading...
Searching...
No Matches
GlobalContinuousMemoryPool.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5
7
8
9namespace toolbox {
10 namespace particles {
11 namespace memorypool {
12 template <class T>
14 } // namespace memorypool
15 } // namespace particles
16} // namespace toolbox
17
18
72template <class T>
74public:
75 typedef std::list<T*> Container;
76
83
85
96 void scatter();
97
101 typename Container::iterator scatterAndUpdateIterator(const typename Container::iterator& p);
102
122 void gather();
123
129 bool isGathered() const;
130
141 void replace(typename Container::iterator p, T* newCopy);
142
151
160
161private:
163
164 static constexpr int UndefinedMemoryPage = -1;
165
170 struct Page {
172 int size;
173 bool used;
174 };
175 std::vector<T> data;
176 std::vector<Page> pages;
182
186 int totalUsedSize() const;
187
188 GlobalMemory(int initialSize);
189
197 int addPage(int size);
198
214 void freePage(int pageNumber);
215 };
216
226
233
238};
239
240
241#include "GlobalContinuousMemoryPool.cpph"
Log Device.
Definition Log.h:517
Memory pool offering continuous global memory for a particle species.
static GlobalMemory _globalMemory
This class attribute represents the global data space for all of the particles.
Container::iterator scatterAndUpdateIterator(const typename Container::iterator &p)
void clearAndReset()
Clear dataset tied to one vertex.
T * _gatheredDataPointer
Is nullptr as long as data is not gathered.
int _globalMemoryPage
Equals UndefinedPoolReference as long as data is not gathered.
static bool requestCompleteScatter()
Recommend complete scatter.
bool isGathered() const
Is the vertex data gathered.
void replace(typename Container::iterator p, T *newCopy)
Replace particle.
int totalUsedSize() const
Take last page's start index, add its size and you get the result.
int additionalEntriesRequested
Number of entries that we would have liked to have.