-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Make instance manager conform to Swift 6 principles #13933
Merged
Conversation
This file contains 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
paulb777
approved these changes
Oct 19, 2024
FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift
Outdated
Show resolved
Hide resolved
andrewheard
approved these changes
Oct 21, 2024
FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift
Outdated
Show resolved
Hide resolved
paulb777
approved these changes
Oct 23, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem:
Static property 'cachedInstances' is not concurrency-safe because it is nonisolated global shared mutable state
The fix-it to add
nonisolated(unsafe)
is for when it's okay toDisable concurrency-safety checks if accesses are protected by an external synchronization mechanism
.The "external synchronization mechanism" is the added lock. I went with
NSLock
ofos_unfair_lock
because the latter would need to be anotherstatic var
and require an extranonisolated(unsafe)
attribute. This would be technically okay, but it looked cleaner to use the NSLock. NSLock is slightly slower but I think it would have a negligible effect based on the use case here.Because core internal has < iOS 13 availability, structured concurrency cannot be used.
The added test crashes with the current implementation, and succeeds with this PR's changes.
#no-changelog