OpenCoverage

qrecyclepool_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/ftw/qrecyclepool_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#ifndef QRECYCLEPOOL_P_H-
41#define QRECYCLEPOOL_P_H-
42-
43//-
44// W A R N I N G-
45// --------------
46//-
47// This file is not part of the Qt API. It exists purely as an-
48// implementation detail. This header file may change from version to-
49// version without notice, or even be removed.-
50//-
51// We mean it.-
52//-
53-
54QT_BEGIN_NAMESPACE-
55-
56#define QRECYCLEPOOLCOOKIE 0x33218ADF-
57-
58template<typename T, int Step>-
59class QRecyclePoolPrivate-
60{-
61public:-
62 QRecyclePoolPrivate()-
63 : recyclePoolHold(true), outstandingItems(0), cookie(QRECYCLEPOOLCOOKIE),-
64 currentPage(nullptr), nextAllocated(nullptr)-
65 {-
66 }
never executed: end of block
0
67-
68 bool recyclePoolHold;-
69 int outstandingItems;-
70 quint32 cookie;-
71-
72 struct PoolType : public T {-
73 union {-
74 QRecyclePoolPrivate<T, Step> *pool;-
75 PoolType *nextAllocated;-
76 };-
77 };-
78-
79 struct Page {-
80 Page *nextPage;-
81 unsigned int free;-
82 union {-
83 char array[Step * sizeof(PoolType)];-
84 qint64 q_for_alignment_1;-
85 double q_for_alignment_2;-
86 };-
87 };-
88-
89 Page *currentPage;-
90 PoolType *nextAllocated;-
91-
92 inline T *allocate();-
93 static inline void dispose(T *);-
94 inline void releaseIfPossible();-
95};-
96-
97template<typename T, int Step = 1024>-
98class QRecyclePool-
99{-
100public:-
101 inline QRecyclePool();-
102 inline ~QRecyclePool();-
103-
104 inline T *New();-
105 template<typename T1>-
106 inline T *New(const T1 &);-
107 template<typename T1>-
108 inline T *New(T1 &);-
109-
110 static inline void Delete(T *);-
111-
112private:-
113 QRecyclePoolPrivate<T, Step> *d;-
114};-
115-
116template<typename T, int Step>-
117QRecyclePool<T, Step>::QRecyclePool()-
118: d(new QRecyclePoolPrivate<T, Step>())-
119{-
120}
never executed: end of block
0
121-
122template<typename T, int Step>-
123QRecyclePool<T, Step>::~QRecyclePool()-
124{-
125 d->recyclePoolHold = false;-
126 d->releaseIfPossible();-
127}
never executed: end of block
0
128-
129template<typename T, int Step>-
130T *QRecyclePool<T, Step>::New()-
131{-
132 T *rv = d->allocate();-
133 new (rv) T;-
134 return rv;
never executed: return rv;
0
135}-
136-
137template<typename T, int Step>-
138template<typename T1>-
139T *QRecyclePool<T, Step>::New(const T1 &a)-
140{-
141 T *rv = d->allocate();-
142 new (rv) T(a);-
143 return rv;
never executed: return rv;
0
144}-
145-
146template<typename T, int Step>-
147template<typename T1>-
148T *QRecyclePool<T, Step>::New(T1 &a)-
149{-
150 T *rv = d->allocate();-
151 new (rv) T(a);-
152 return rv;
executed 926499 times by 114 tests: return rv;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
926499
153}-
154-
155template<typename T, int Step>-
156void QRecyclePool<T, Step>::Delete(T *t)-
157{-
158 t->~T();-
159 QRecyclePoolPrivate<T, Step>::dispose(t);-
160}
executed 845675 times by 113 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
845675
161-
162template<typename T, int Step>-
163void QRecyclePoolPrivate<T, Step>::releaseIfPossible()-
164{-
165 if (recyclePoolHold || outstandingItems)
recyclePoolHoldDescription
TRUEevaluated 821917 times by 112 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • tst_qqmlstatemachine
  • ...
FALSEevaluated 23758 times by 9 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlinstantiator
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
outstandingItemsDescription
TRUEevaluated 23499 times by 9 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlinstantiator
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 259 times by 8 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
259-821917
166 return;
executed 845416 times by 113 tests: return;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
845416
167-
168 Page *p = currentPage;-
169 while (p) {
pDescription
TRUEevaluated 265 times by 8 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
FALSEevaluated 259 times by 8 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
259-265
170 Page *n = p->nextPage;-
171 free(p);-
172 p = n;-
173 }
executed 265 times by 8 tests: end of block
Executed by:
  • tst_qqmlecmascript
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
265
174-
175 delete this;-
176}
executed 259 times by 8 tests: end of block
Executed by:
  • tst_qqmlecmascript
  • tst_qquickgridview
  • tst_qquickitem2
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
259
177-
178template<typename T, int Step>-
179T *QRecyclePoolPrivate<T, Step>::allocate()-
180{-
181 PoolType *rv = nullptr;-
182 if (nextAllocated) {
nextAllocatedDescription
TRUEevaluated 609254 times by 36 tests
Evaluated by:
  • tst_examples
  • tst_flickableinterop
  • tst_qmldiskcache
  • tst_qqmlbinding
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlitemmodels
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlvaluetypes
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • tst_qquickflickable
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickitem2
  • tst_qquicklayouts
  • ...
FALSEevaluated 317245 times by 114 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
317245-609254
183 rv = nextAllocated;-
184 nextAllocated = rv->nextAllocated;-
185 } else if (currentPage && currentPage->free) {
executed 609254 times by 36 tests: end of block
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_qmldiskcache
  • tst_qqmlbinding
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlitemmodels
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlvaluetypes
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • tst_qquickflickable
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickitem2
  • tst_qquicklayouts
  • ...
currentPageDescription
TRUEevaluated 313735 times by 93 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • tst_qqmlstatemachine
  • ...
FALSEevaluated 3510 times by 114 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
currentPage->freeDescription
TRUEevaluated 313633 times by 93 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • tst_qqmlstatemachine
  • ...
FALSEevaluated 102 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmlnotifier
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_scenegraph
102-609254
186 rv = (PoolType *)(currentPage->array + (Step - currentPage->free) * sizeof(PoolType));-
187 currentPage->free--;-
188 } else {
executed 313633 times by 93 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • tst_qqmlstatemachine
  • ...
313633
189 Page *p = (Page *)malloc(sizeof(Page));-
190 p->nextPage = currentPage;-
191 p->free = Step;-
192 currentPage = p;-
193-
194 rv = (PoolType *)currentPage->array;-
195 currentPage->free--;-
196 }
executed 3612 times by 114 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
3612
197-
198 rv->pool = this;-
199 ++outstandingItems;-
200 return rv;
executed 926499 times by 114 tests: return rv;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
926499
201}-
202-
203template<typename T, int Step>-
204void QRecyclePoolPrivate<T, Step>::dispose(T *t)-
205{-
206 PoolType *pt = static_cast<PoolType *>(t);-
207 Q_ASSERT(pt->pool && pt->pool->cookie == QRECYCLEPOOLCOOKIE);-
208-
209 QRecyclePoolPrivate<T, Step> *This = pt->pool;-
210 pt->nextAllocated = This->nextAllocated;-
211 This->nextAllocated = pt;-
212 --This->outstandingItems;-
213 This->releaseIfPossible();-
214}
executed 845675 times by 113 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • tst_qqmlitemmodels
  • tst_qqmllistmodel
  • tst_qqmllistreference
  • tst_qqmllocale
  • tst_qqmlnotifier
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlqt
  • ...
845675
215-
216QT_END_NAMESPACE-
217-
218#endif // QRECYCLEPOOL_P_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0