bitstadium / HockeySDK-iOS

HockeyApp was retired and the SDKs are deprecated. Please use App Center instead.
https://github.com/microsoft/appcenter-sdk-apple
Other
597 stars 268 forks source link

Fix/metrics manager trackevent threadsafe #471

Closed ElektrojungeAtWork closed 7 years ago

ElektrojungeAtWork commented 7 years ago

Hopefully a more thorough approach to making BITChannel thread-safe.

I'm combining mutexes and atomic compare and swap based on https://github.com/bitstadium/HockeySDK-iOS/pulls and https://github.com/bitstadium/HockeySDK-Mac/pull/106.

From testing, this works great. I'm happy for as many pairs of eyes as possible.

ElektrojungeAtWork commented 7 years ago

I discussed this PR with @gwynne to a great length. While my approach above doesn't 100% guarantee safety, it's a step in the right direction. Ultimately, we need to move this implementation to a linked-list implementation similar to what we have in Mobile Center but this requires several days of work.

Please let me know if you have objections, otherwise I'll merge the PR.

ElektrojungeAtWork commented 7 years ago

I talked to Gwynne about this to a great deal and bottom line is that this PR is as best as we can do without refactoring the whole buffer logic into something that uses a proper, threadsafe linked list (similar to what we use for Mobile Center). That said, this PR improves thread safety a lot, so let me know if you have concerns about merging this.