-
Notifications
You must be signed in to change notification settings - Fork 94
feat(events): add flushAndWait on Apple (tier 2) #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abelonogov-ld
wants to merge
15
commits into
andrey/event-durability-tier1-buffer
Choose a base branch
from
andrey/event-durability-tier2-bounded-flush
base: andrey/event-durability-tier1-buffer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
05b5628
feat(events): add flushAndWait on Apple (tier 2)
abelonogov-ld 5420c2c
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld a4a1bf1
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 41c02e1
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 5842339
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld c0cabc2
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 92f17c9
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 2f8e528
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 86277e6
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld 7d70ae6
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld fd1381c
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld dc9d1e6
fix(events): answer a bounded flush about the delivery already in flight
abelonogov-ld 6c3b8f9
shorten comments
abelonogov-ld 57f04c3
fix(events): report a closed client and a refused in-flight delivery …
abelonogov-ld 47700b3
Merge branch 'andrey/event-durability-tier1-buffer' into andrey/event…
abelonogov-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
31 changes: 31 additions & 0 deletions
31
LaunchDarkly/LaunchDarkly/ServiceObjects/BackgroundActivity.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import Foundation | ||
|
|
||
| /// Holds a background activity assertion so a backgrounded process is not suspended mid-delivery. | ||
| /// | ||
| /// Uses `ProcessInfo.performExpiringActivity` because the framework is extension-safe and cannot use | ||
| /// `UIApplication.beginBackgroundTask`. The system may refuse or end the assertion early. | ||
| enum BackgroundActivity { | ||
| /// Upper bound for work that never calls `finished`. | ||
| private static let maximumDuration: TimeInterval = 30 | ||
|
|
||
| /// Runs `work` under an assertion released when `work` calls `finished`, the system expires it, or | ||
| /// `maximumDuration` passes. Without assertions on this platform, `work` runs on the calling thread. | ||
| static func run(reason: String, work: @escaping (_ finished: @escaping () -> Void) -> Void) { | ||
| #if os(iOS) || os(tvOS) || os(watchOS) | ||
| let finished = DispatchSemaphore(value: 0) | ||
| ProcessInfo.processInfo.performExpiringActivity(withReason: reason) { expired in | ||
| guard !expired | ||
| else { | ||
| // Expiration: release the blocked first call. | ||
| finished.signal() | ||
| return | ||
| } | ||
| work { finished.signal() } | ||
| // The assertion lasts as long as this block, which runs on a system queue, not main. | ||
| _ = finished.wait(timeout: .now() + maximumDuration) | ||
| } | ||
| #else | ||
| work {} | ||
| #endif | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.