Skip to content

NR-586737 changed reachability to update a callback on change instead of calling it every time#814

Open
mbruin-NR wants to merge 1 commit into
developfrom
NR-586737
Open

NR-586737 changed reachability to update a callback on change instead of calling it every time#814
mbruin-NR wants to merge 1 commit into
developfrom
NR-586737

Conversation

@mbruin-NR

Copy link
Copy Markdown
Contributor
  1. _Atomic(int) _cachedStatus ivar — lock-free cache for the last known status. int rather than the enum directly to avoid any C11 _Atomic-on-enum edge cases.
  2. NRMAReachabilityCallback + setup in +reachability — one synchronous SCNetworkReachabilityGetFlags call at creation time primes the cache, thenSCNetworkReachabilitySetDispatchQueue hands off all future updates to a utility queue. After this, no thread ever blocks on reachability.
  3. dealloc — cancels the callback and queue before CFRelease. This is the critical safety pairing:text (non-owning) is safe only because dealloc guarantees no callback fires after the object is freed.
  4. CurrentReachabilityStatus that checkOfflineStatus called on every event no longer touches the Network framework.

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.

3 participants