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.
Issue Link π
#3480
Goals β½
This PR makes
Session'sconvenience inita bit safer by retargeting the providedrootQueueonto a serial queue with the same label before using it as thedelegateQueueand passing it to the root initializer.Unfortunately we can't do the same thing in the root initializer, as creating an additional layer of
DispatchQueueonce thedelegateQueuehas been created means that all of ourdispatchPrecondition(condition: .onQueue(queue))checks fail, as the delegate queue would no longer be in the same hierarchy with the retargetedrootQueue. 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
DispatchQueuetargeting the providedrootQueueto use as the actualrootQueue.Testing Details π
An additional test has been added which uses a concurrent queue as the
rootQueueto demonstrate the safety of this approach.