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

Safer Custom rootQueues #3523

Merged
merged 3 commits into from
Nov 16, 2021
Merged

Safer Custom rootQueues #3523

merged 3 commits into from
Nov 16, 2021

Conversation

jshier
Copy link
Contributor

@jshier jshier commented Nov 15, 2021

Issue Link πŸ”—

#3480

Goals ⚽

This PR makes Session's convenience init a bit safer by retargeting the provided rootQueue onto a serial queue with the same label before using it as the delegateQueue and passing it to the root initializer.

Unfortunately we can't do the same thing in the root initializer, as creating an additional layer of DispatchQueue once the delegateQueue has been created means that all of our dispatchPrecondition(condition: .onQueue(queue)) checks fail, as the delegate queue would no longer be in the same hierarchy with the retargeted rootQueue. However, we do still get some benefit here, as it would've prevent the bug reported in #3480.

Implementation Details 🚧

This PR simply creates a new serial DispatchQueue targeting the provided rootQueue to use as the actual rootQueue.

Testing Details πŸ”

An additional test has been added which uses a concurrent queue as the rootQueue to demonstrate the safety of this approach.

@jshier jshier merged commit 65b7769 into master Nov 16, 2021
@jshier jshier deleted the update/safer-rootQueue branch November 16, 2021 00:34
@jshier jshier added this to the 5.5.0 milestone Dec 13, 2021
jshier added a commit that referenced this pull request Jan 15, 2022
* Add queue targeting to convenience init.

* Formatting.

* Don't retarget the main queue.
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.

None yet

1 participant