Skip to content
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

Remove semaphore from PersistentHitQueue #1042

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

praveek
Copy link
Contributor

@praveek praveek commented Jun 4, 2024

The DispatchSemaphore was initially used to block the async queue until a hit was processed by the hit processor, ensuring sequential handling. However, this caused unnecessary thread creation, especially during app launch when multiple extensions send hits.

This semaphore became redundant once we started using the isTaskScheduled variable to guard the processNextHit method. The isTaskScheduled variable ensures new hits will not be processed until the current hit is completed or retried.

Also updated the completion logic to access all internal state using the internal queue to avoid race conditions especially when updating isTaskScheduled.

@@ -18,7 +18,7 @@ public class PersistentHitQueue: HitQueuing {

private var suspended = true
private var isTaskScheduled = false
private let queue = DispatchQueue(label: "com.adobe.mobile.persistenthitqueue")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it looks like we are using the mobile identifier in a few other places. Do we want to remove it from all of those as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will update them separately.

@praveek praveek marked this pull request as ready for review June 4, 2024 16:55
@praveek praveek merged commit 5bf2cee into adobe:dev-v5.1.1 Jun 4, 2024
17 checks passed
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