@@ -116,6 +116,7 class VariableController2::VariableController2Private | |||||
116 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; |
|
116 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; | |
117 | QReadWriteLock _lock{QReadWriteLock::Recursive}; |
|
117 | QReadWriteLock _lock{QReadWriteLock::Recursive}; | |
118 | }_maps; |
|
118 | }_maps; | |
|
119 | std::vector<QUuid> _variablesToRemove; | |||
119 | QThreadPool* _ThreadPool; |
|
120 | QThreadPool* _ThreadPool; | |
120 | VCTransactionsQueues _transactions; |
|
121 | VCTransactionsQueues _transactions; | |
121 | std::unique_ptr<VariableCacheStrategy> _cacheStrategy; |
|
122 | std::unique_ptr<VariableCacheStrategy> _cacheStrategy; | |
@@ -129,6 +130,19 class VariableController2::VariableController2Private | |||||
129 | this->_processTransactions(); |
|
130 | this->_processTransactions(); | |
130 | } |
|
131 | } | |
131 |
|
132 | |||
|
133 | void _cleanupVariables() | |||
|
134 | { | |||
|
135 | for(auto id:_variablesToRemove) | |||
|
136 | { | |||
|
137 | auto v = this->variable(id); | |||
|
138 | if(!hasPendingTransactions(v)) | |||
|
139 | { | |||
|
140 | _variablesToRemove.erase(std::remove(_variablesToRemove.begin(), _variablesToRemove.end(), id), _variablesToRemove.end()); | |||
|
141 | this->deleteVariable(v); | |||
|
142 | } | |||
|
143 | } | |||
|
144 | } | |||
|
145 | ||||
132 | void _processTransactions(bool fragmented=false) |
|
146 | void _processTransactions(bool fragmented=false) | |
133 | { |
|
147 | { | |
134 | auto nextTransactions = _transactions.nextTransactions(); |
|
148 | auto nextTransactions = _transactions.nextTransactions(); | |
@@ -173,6 +187,9 class VariableController2::VariableController2Private | |||||
173 | } |
|
187 | } | |
174 | } |
|
188 | } | |
175 | } |
|
189 | } | |
|
190 | //after each transaction update we get a new distribution of idle and working variables | |||
|
191 | //so we can delete variables which are waiting to be deleted if they are now idle | |||
|
192 | _cleanupVariables(); | |||
176 | } |
|
193 | } | |
177 |
|
194 | |||
178 | std::map<QUuid,DateTimeRange> _computeAllRangesInGroup(const std::shared_ptr<Variable>& refVar, DateTimeRange r) |
|
195 | std::map<QUuid,DateTimeRange> _computeAllRangesInGroup(const std::shared_ptr<Variable>& refVar, DateTimeRange r) | |
@@ -304,7 +321,10 public: | |||||
304 |
|
321 | |||
305 | void deleteVariable(const std::shared_ptr<Variable>& variable) |
|
322 | void deleteVariable(const std::shared_ptr<Variable>& variable) | |
306 | { |
|
323 | { | |
307 | _maps.removeVariable(variable); |
|
324 | if(!hasPendingTransactions(variable)) | |
|
325 | _maps.removeVariable(variable); | |||
|
326 | else | |||
|
327 | _variablesToRemove.push_back(variable->ID()); | |||
308 | } |
|
328 | } | |
309 |
|
329 | |||
310 | void asyncChangeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r) |
|
330 | void asyncChangeRange(const std::shared_ptr<Variable>& variable, const DateTimeRange& r) |
@@ -125,6 +125,7 private slots: | |||||
125 | } |
|
125 | } | |
126 | void testCache() |
|
126 | void testCache() | |
127 | { |
|
127 | { | |
|
128 | QSKIP("The cache is disabled for now"); | |||
128 | TEST_VC2_FIXTURE(10); |
|
129 | TEST_VC2_FIXTURE(10); | |
129 | TEST_VC2_CREATE_DEFAULT_VAR(var1); |
|
130 | TEST_VC2_CREATE_DEFAULT_VAR(var1); | |
130 | check_variable_state<RangeType<10>>(var1, range); |
|
131 | check_variable_state<RangeType<10>>(var1, range); |
@@ -61,6 +61,7 private slots: | |||||
61 | auto var1 = vc.createVariable("var1", {}, provider, range); |
|
61 | auto var1 = vc.createVariable("var1", {}, provider, range); | |
62 | QVERIFY(SciQLop::containers::contains(vc.variables(), var1)); |
|
62 | QVERIFY(SciQLop::containers::contains(vc.variables(), var1)); | |
63 | QVERIFY(!callbackCalled); |
|
63 | QVERIFY(!callbackCalled); | |
|
64 | while (!vc.isReady(var1)) {qApp->processEvents();} | |||
64 | vc.deleteVariable(var1); |
|
65 | vc.deleteVariable(var1); | |
65 | QVERIFY(!SciQLop::containers::contains(vc.variables(), var1)); |
|
66 | QVERIFY(!SciQLop::containers::contains(vc.variables(), var1)); | |
66 | QVERIFY(callbackCalled); |
|
67 | QVERIFY(callbackCalled); |
General Comments 0
You need to be logged in to leave comments.
Login now