beeminder / BeeSwift

Official Beeminder for iOS app
Other
29 stars 5 forks source link

Prevent threading bugs in HealthStoreManager #349

Closed theospears closed 1 year ago

theospears commented 1 year ago

HealthStoreManager maintains a global cache of connections. This leads to race conditions when multiple threads simultaneously try to create a connection for the same metric. We could solve this with actors, but do not want to in this case as the silentlyInstallObservers method should be synchronous. Instead we use a sempahore to protect access to the dictionary.