mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:09:56 +02:00
Clarify use of procedural's dirty atomic flag
This commit is contained in:
parent
ff07e47626
commit
1a8cca3dcc
1 changed files with 7 additions and 0 deletions
|
@ -77,6 +77,9 @@ void Procedural::parse(const QString& userDataJson) {
|
||||||
// This will be called by Procedural::ready
|
// This will be called by Procedural::ready
|
||||||
std::lock_guard<std::mutex> lock(_proceduralDataMutex);
|
std::lock_guard<std::mutex> lock(_proceduralDataMutex);
|
||||||
_proceduralData = proceduralData.toObject();
|
_proceduralData = proceduralData.toObject();
|
||||||
|
|
||||||
|
// Mark as dirty after modifying _proceduralData, but before releasing lock
|
||||||
|
// to avoid setting it after parsing has begun
|
||||||
_proceduralDataDirty = true;
|
_proceduralDataDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,9 +169,13 @@ void Procedural::parse(const QJsonObject& proceduralData) {
|
||||||
|
|
||||||
bool Procedural::ready() {
|
bool Procedural::ready() {
|
||||||
// Load any changes to the procedural
|
// Load any changes to the procedural
|
||||||
|
// Check for changes atomically, in case they are currently being made
|
||||||
if (_proceduralDataDirty) {
|
if (_proceduralDataDirty) {
|
||||||
std::lock_guard<std::mutex> lock(_proceduralDataMutex);
|
std::lock_guard<std::mutex> lock(_proceduralDataMutex);
|
||||||
parse(_proceduralData);
|
parse(_proceduralData);
|
||||||
|
|
||||||
|
// Reset dirty flag after reading _proceduralData, but before releasing lock
|
||||||
|
// to avoid resetting it after more data is set
|
||||||
_proceduralDataDirty = false;
|
_proceduralDataDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue