Make core types Sendable and @unchecked Sendable#308
Conversation
| @available(watchOS 3, *) | ||
| public final class SinglePromptSecureEnclaveValet: NSObject { | ||
| public final class SinglePromptSecureEnclaveValet: NSObject, @unchecked Sendable { |
There was a problem hiding this comment.
The localization context is a var on the type. It's only mutated within a lock, so we are indeed sendable. But the compiler won't be convinced of that... so we use unchecked.
| private var baseKeychainQuery: [String : AnyHashable] { | ||
| return service.generateBaseQuery() | ||
| } |
There was a problem hiding this comment.
I don't love this, but AnyHashable isn't Sendable and service.generateBaseQuery() is fast, so in the tug-of-war between "have the compiler check the thing I know is safe" and "we know it's safe so opt out of checking to do something faster" I'm leaning towards the former.
I generally lean towards calling dropped Xcode support a breaking change, but the "haven't been able to ship to the App Store with these versions for years" is an interesting mitigating factor. I'm okay with dropping that as a minor version bump. 👍 |
We've been thread-safe since v1. We just hadn't told the compiler this fact yet.
This PR won't compile on Xcode 12.4 or prior, and we currently support back to Xcode 11. We therefore have two options:
I'd be curious to hear from @pwesten and friends how they'd like to approach this before I go and update the README on this PR.