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 {
195
195
}
196
196
)
197
197
}
198
-
199
198
}
200
199
201
200
// MARK: - Test helpers
@@ -354,8 +353,11 @@ fileprivate extension TaskScheduler<ClosureTaskDescription> {
354
353
body,
355
354
dependencies: dependencies
356
355
)
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)
357
359
return Task ( priority: priority) {
358
- await self . schedule ( priority : priority , taskDescription ) . waitToFinishPropagatingCancellation ( )
360
+ await queuedTask . waitToFinishPropagatingCancellation ( )
359
361
}
360
362
}
361
363
}
You can’t perform that action at this time.
0 commit comments