Repository navigation
Preserve ordered delivery for concurrent subject sends - #64
Closed
mikamikasuki wants to merge 1 commit into
Closed
mikamikasuki wants to merge 1 commit into
mikamikasuki wants to merge 1 commit into
Conversation
Contributor
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.
Description
Closes #61.
Concurrent calls to
sendcan update a subject's state in one order but deliver snapshots to consumers in another. This can leave subscribers with different event orders, or make a current-value or replay subscriber finish with a value older than the subject's latest state.This change queues each delivery while holding the subject state lock, then drains the FIFO queue after releasing that lock. A single drainer preserves the state-update order across all six subject variants while keeping consumer resumption outside the subject and queue locks, so cancellation handlers can safely re-enter the subject.
The change also adds concurrent-send ordering and cancellation-handler regression tests and updates the Unreleased changelog.
Validation
swift buildpasses.swift test --filter AsyncSubjectConcurrentSendOrderingTestscould not run on this host because XCTest is unavailable (no such module XCTest). The added test source was typechecked separately.Checklist