54 #include <QtCore/private/qglobal_p.h>
55 #include <QtCore/qatomic.h>
93 inline void t()
const { }
118 InitialNextValue = 0,
119 IndexMask = 0x00ffffff,
120 SerialMask = ~IndexMask & ~0x80000000,
121 SerialCounter = IndexMask + 1,
122 MaxIndex = IndexMask,
126 static const int Sizes[BlockCount];
146 template <
typename T,
typename ConstantsType = QFreeListDefaultConstants>
155 static inline int blockfor(
int &
x)
157 for (
int i = 0;
i < ConstantsType::BlockCount; ++
i) {
158 int size = ConstantsType::Sizes[
i];
178 static inline int incrementserial(
int o,
int n)
180 return int((
uint(
n) & ConstantsType::IndexMask) | ((
uint(
o) + ConstantsType::SerialCounter) & ConstantsType::SerialMask));
196 inline ConstReferenceType
at(
int x)
const;
207 template <
typename T,
typename ConstantsType>
211 _next(ConstantsType::InitialNextValue)
214 template <
typename T,
typename ConstantsType>
217 for (
int i = 0;
i < ConstantsType::BlockCount; ++
i)
218 delete [] _v[
i].loadAcquire();
221 template <
typename T,
typename ConstantsType>
224 const int block = blockfor(
x);
225 return (_v[
block].loadRelaxed())[
x].t();
228 template <
typename T,
typename ConstantsType>
231 const int block = blockfor(
x);
232 return (_v[
block].loadRelaxed())[
x].t();
235 template <
typename T,
typename ConstantsType>
241 id = _next.loadAcquire();
243 at =
id & ConstantsType::IndexMask;
244 const int block = blockfor(
at);
245 v = _v[
block].loadAcquire();
248 v = allocate((
id & ConstantsType::IndexMask) -
at, ConstantsType::Sizes[
block]);
249 if (!_v[
block].testAndSetRelease(
nullptr,
v)) {
252 v = _v[
block].loadAcquire();
257 newid =
v[
at].next.loadRelaxed() | (
id & ~ConstantsType::IndexMask);
258 }
while (!_next.testAndSetRelease(
id, newid));
263 return id & ConstantsType::IndexMask;
266 template <
typename T,
typename ConstantsType>
269 int at =
id & ConstantsType::IndexMask;
270 const int block = blockfor(
at);
275 x = _next.loadAcquire();
276 v[
at].next.storeRelaxed(
x & ConstantsType::IndexMask);
278 newid = incrementserial(
x,
id);
279 }
while (!_next.testAndSetRelease(
x, newid));
small capitals from c petite p scientific i
[1]
The QAtomicInt class provides platform-independent atomic operations on int.
The QAtomicPointer class is a template class that provides platform-independent atomic operations on ...
ReferenceType operator[](int x)
ConstReferenceType at(int x) const
#define Q_DISABLE_COPY_MOVE(Class)
#define Q_AUTOTEST_EXPORT
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLintptr offset
const T & ConstReferenceType
ConstReferenceType t() const