[6.2][Concurrency] Improve in order synchronous enqueue of startSynchronously #80852
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.
Description:
Previously there was still a sneaky hop which caused ordering issues. This introduced a specific test startSynchronously_order which checks that the task enqueues indeed are "immediate" and cleans up how we handle this.
This also prepares for the being discussed in SE review direction of this API that it SHOULD be ALLOWED to actually hop and NOT be synchronous at all IF the isolation is specified on the closure and is DIFFERENT than the callers dynamic isolation.
This effectively implements "synchronously run right now if dynamically on the exact isolation as requested by the closure; otherwise enqueue the task as usual".
Scope/Impact: Specifically fixes run order of the "synchronously start task" when nonisolated target closure
Risk: Low, fixes semantics of new API in 6.2
Testing: New test to verify the enqueue order
Reviewed by: @drexin
Original PR: #80821
Radar: rdar://149284186