Skip to content

Commit

Permalink
Move properties model's change propagation outside of the lock
Browse files Browse the repository at this point in the history
* Keep the lock minimal, just around write and read access to the tags dictionary
* Move the events-driving outside of the lock, that create Deltas and caches the model, etc.
  • Loading branch information
nan-li committed Apr 19, 2024
1 parent 500923d commit 9101482
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ class OSPropertiesModel: OSModel {
for (key, value) in tags {
self.tags[key] = value
}
self.set(property: "tags", newValue: tags)
}
self.set(property: "tags", newValue: tags)
}

func removeTags(_ tags: [String]) {
var tagsToSend: [String: String] = [:]
tagsLock.withLock {
var tagsToSend: [String: String] = [:]
for tag in tags {
self.tags.removeValue(forKey: tag)
tagsToSend[tag] = ""
}
self.set(property: "tags", newValue: tagsToSend)
}
self.set(property: "tags", newValue: tagsToSend)
}

public override func hydrateModel(_ response: [String: Any]) {
Expand Down

0 comments on commit 9101482

Please sign in to comment.