-
Notifications
You must be signed in to change notification settings - Fork 10
2.7.10 #392
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
Merged
2.7.10 #392
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
712e644
Adds prioritized campaigns support
ianrumac 4b794c0
Improve error messages for billing errors
ianrumac 06d54a9
Add guard to prevent pw from dismissing on deep link
ianrumac 869619e
Fix compose reference
ianrumac 7d63808
Add onboarding analytics support
ianrumac 75b6fdb
Merge pull request #391 from superwall/ir/feat/pw_analytics
ianrumac 43009a4
Merge pull request #390 from superwall/ir/fix/deep-link-dismiss
ianrumac a6ccdd7
Fix treatment of bottom sheet for samsungs
ianrumac 2d29664
Merge pull request #386 from superwall/ir/feat/prioritized-campaigns
ianrumac a472380
Ensure serial task manager never blocks by migrating to channel
ianrumac 60b1b32
Update version & Changelog
ianrumac 8b70137
Fix changelog message
ianrumac e948e9a
Fix double preload bug
ianrumac dbfd0bd
Changelog update
ianrumac 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
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
52 changes: 17 additions & 35 deletions
52
superwall/src/main/java/com/superwall/sdk/misc/SerialTaskManager.kt
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 |
|---|---|---|
| @@ -1,50 +1,32 @@ | ||
| package com.superwall.sdk.misc | ||
|
|
||
| import com.superwall.sdk.logger.LogLevel | ||
| import com.superwall.sdk.logger.LogScope | ||
| import com.superwall.sdk.logger.Logger | ||
| import kotlinx.coroutines.* | ||
| import java.util.* | ||
| import java.util.LinkedList | ||
| import java.util.Queue | ||
| import kotlinx.coroutines.channels.Channel | ||
|
|
||
| class SerialTaskManager( | ||
| private val coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO.limitedParallelism(1)), | ||
| private val coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO), | ||
| ) { | ||
| private val taskQueue: Queue<suspend () -> Unit> = LinkedList() | ||
| private var currentTask: Deferred<Unit>? = null | ||
| private val channel = Channel<suspend () -> Unit>(Channel.UNLIMITED) | ||
|
|
||
| fun addTask(task: suspend () -> Unit) { | ||
| init { | ||
| coroutineScope.launch { | ||
| // Wait for the current task to finish if there is one | ||
| currentTask?.await() | ||
|
|
||
| // Add the task to the queue | ||
| taskQueue.offer(task) | ||
|
|
||
| // If there's only one task in the queue, start executing it | ||
| if (taskQueue.size == 1) { | ||
| executeNextTask() | ||
| for (task in channel) { | ||
| task() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private suspend fun executeNextTask() { | ||
| // Check if there are tasks in the queue | ||
| if (taskQueue.isEmpty()) { | ||
| return | ||
| } | ||
|
|
||
| // Get the next task from the queue | ||
| val nextTask = taskQueue.poll() ?: return | ||
|
|
||
| // Run the task and wait for it to complete | ||
| currentTask = | ||
| coroutineScope.async { | ||
| nextTask() | ||
| } | ||
| currentTask?.await() | ||
|
|
||
| // After the task completes, recursively execute the next task | ||
| if (taskQueue.isNotEmpty()) { | ||
| executeNextTask() | ||
| fun addTask(task: suspend () -> Unit) { | ||
| val result = channel.trySend(task) | ||
| if (result.isFailure) { | ||
| Logger.debug( | ||
| logLevel = LogLevel.error, | ||
| scope = LogScope.superwallCore, | ||
| message = "SerialTaskManager: failed to enqueue task — channel closed", | ||
| ) | ||
| } | ||
| } | ||
| } |
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
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
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.