File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,6 @@ final class TaskSchedulerTests: XCTestCase {
195195 }
196196 )
197197 }
198-
199198}
200199
201200// MARK: - Test helpers
@@ -354,8 +353,11 @@ fileprivate extension TaskScheduler<ClosureTaskDescription> {
354353 body,
355354 dependencies: dependencies
356355 )
356+ // Make sure that we call `schedule` outside of the `Task` because the execution order of `Task`s is not guaranteed
357+ // and if we called `schedule` inside `Task`, Swift concurrency can re-order the order that we schedule tasks in.
358+ let queuedTask = await self . schedule ( priority: priority, taskDescription)
357359 return Task ( priority: priority) {
358- await self . schedule ( priority : priority , taskDescription ) . waitToFinishPropagatingCancellation ( )
360+ await queuedTask . waitToFinishPropagatingCancellation ( )
359361 }
360362 }
361363}
You can’t perform that action at this time.
0 commit comments