Skip to content

Serialize event observer mutations - #24

Closed
rchatham wants to merge 2 commits into
feature/network-migration-ci-baselinefrom
feature/network-migration-threadsafe-events
Closed

Serialize event observer mutations#24
rchatham wants to merge 2 commits into
feature/network-migration-ci-baselinefrom
feature/network-migration-threadsafe-events

Conversation

@rchatham

Copy link
Copy Markdown
Owner

Summary

Continues the Network migration PR series by making the existing event observer pipeline safe for concurrent delegate and Network callback delivery.

Changes

  • Protect Observable observer/value storage with NSLock.
  • Protect MultiObservable observer/value storage with NSLock.
  • Snapshot observer lists under lock and invoke callbacks outside the lock to avoid reentrant deadlocks.
  • Add removeAllObservers() helpers instead of directly mutating observer storage from callers.
  • Protect PeerConnectionResponder listener bookkeeping with NSLock.
  • Update PeerConnectionManager.stop() to clear observers through the new synchronized helper.
  • Add concurrency-focused tests for concurrent observer mutation, event delivery, self-removal during delivery, and responder listener removal.

Verification

  • swift test
  • xcodebuild test -project PeerConnectivity.xcodeproj -scheme PeerConnectivity -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.3.1' -configuration Debug
  • xcodebuild test -project PeerConnectivity.xcodeproj -scheme PeerConnectivity -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.3.1' -configuration Debug -enableThreadSanitizer YES -only-testing:PeerConnectivityTests/ObservableThreadSafetyTests

Notes

  • This is intended as a stacked follow-up on PR Add Network migration CI baseline #23 (feature/network-migration-ci-baseline).
  • No public API or runtime backend selection changes are included.
  • Callback delivery ordering is unchanged for single-threaded callers; concurrent producers are serialized only around observer storage, not globally ordered across producer queues.

…eline' into HEAD

# Conflicts:
#	PeerConnectivity.xcodeproj/project.pbxproj
@rchatham

Copy link
Copy Markdown
Owner Author

Superseded by consolidated PR #29. No commits were discarded; this branch is preserved as a recovery and reference point. Addressed review findings were replied to and resolved before consolidation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant