Tighten safety on FlagValueSourceCoordinator #127
Merged
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.



📒 Description
FlagValueSourceCoordinator initializer wasn't safe if the non-sendable source continued to be used after it was secured by the lock.
🔍 Detailed Design
This PR splits the FlagValueSourceCoordinator initializer in two:
The first makes it clear (
unchecked) that the operation is unsafe. I've chosen "unchecked" by analogy withOSAllocatedUnfairLock./// Create a FlagValueSource from a NonSendableFlagValueSource. If `Source` is a reference type, /// you must not continue to access it (except via this coordinator) after passing it to this /// initializer. public init(uncheckedSource source: Source) { ... }The second, available in Swift 6 and later, makes the operation safe by guaranteeing that the non-Sendable value can't be shared outside the lock:
📓 Documentation Plan
This type is not yet documented outside doc comments. I haven't added any, though.
🗳 Test Plan
FVSC is not currently tested. I haven't added any, though.
🧯 Source Impact
FVSC is new to Vexil 3, so this isn't [more] breaking to users of 2.x
✅ Checklist