mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 00:04:18 +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
|
||||
std::lock_guard<std::mutex> lock(_proceduralDataMutex);
|
||||
_proceduralData = proceduralData.toObject();
|
||||
|
||||
// Mark as dirty after modifying _proceduralData, but before releasing lock
|
||||
// to avoid setting it after parsing has begun
|
||||
_proceduralDataDirty = true;
|
||||
}
|
||||
|
||||
|
@ -166,9 +169,13 @@ void Procedural::parse(const QJsonObject& proceduralData) {
|
|||
|
||||
bool Procedural::ready() {
|
||||
// Load any changes to the procedural
|
||||
// Check for changes atomically, in case they are currently being made
|
||||
if (_proceduralDataDirty) {
|
||||
std::lock_guard<std::mutex> lock(_proceduralDataMutex);
|
||||
parse(_proceduralData);
|
||||
|
||||
// Reset dirty flag after reading _proceduralData, but before releasing lock
|
||||
// to avoid resetting it after more data is set
|
||||
_proceduralDataDirty = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue