PriceFormatterProvider: Sendable conformance and fixed thread-safety#1806
Merged
NachoSoto merged 3 commits intoAug 13, 2022
Merged
Conversation
c6208d6 to
e2048c7
Compare
This class was used all over the place but it wasn't thread-safe. The Swift compiler enforces this now that it conforms to Sendable (note it's not unchecked!). Because `Atomic` guarantees correctness, this thread-safety can be enforced now by the compiler.
d078ed5 to
d0d818d
Compare
NachoSoto
commented
Aug 9, 2022
PriceFormatterProvider: Sendable conformancePriceFormatterProvider: Sendable conformance and fixed thread-safety
Merged
aboedo
approved these changes
Aug 12, 2022
| #if swift(>=5.7) | ||
| extension Lock: Sendable {} | ||
| #else | ||
| // `NSRecursiveLock` isn't `Sendable` until iOS 16.0 / Swift 5.7 |
NachoSoto
added a commit
that referenced
this pull request
Aug 31, 2022
Fixes [CSDK-379] and #1041 (comment) [CSDK-379]: https://revenuecats.atlassian.net/browse/CSDK-379?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ### Main changes: - `Sendable` conformances to all types that are thread-safe - `@unchecked Sendable` for types that the compiler can't enforce, but with documentation as to why - Made classes that aren't mocked `final` (note that this doesn't change the API, because none of these were `open` to begin with) - Made some classes thread-safe that weren't (like `DeviceCache`) For the non-`final` `class`es, I've actually managed to compile the SDK with all of them as `final` and `Sendable`, to make sure that making them `@unchecked Sendable` didn't hide any other issues. ### Future improvements: - https://twitter.com/nachosoto/status/1557139992056500224?s=21&t=arWdvEzTIFANBvwqQ0vPiA - https://twitter.com/nachosoto/status/1557141944777592832?s=21&t=arWdvEzTIFANBvwqQ0vPiA - https://twitter.com/nachosoto/status/1557143374922059776?s=21&t=arWdvEzTIFANBvwqQ0vPiA ### Depends on: - #1794 - #1804 - #1806 - #1807 - #1808 - #1813 - #1822 - #1823 - #1824 - #1825 - #1826
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For CSDK-379.
This class was used all over the place but it wasn't thread-safe. The Swift compiler enforces this now that it conforms to Sendable (note it's not unchecked!).
Because
Atomicguarantees correctness, this thread-safety can be enforced now by the compiler.