Skip to content

Commit 250081e

Browse files
committed
Fix theoretical issue in withTaskPriorityChangedHandler that could always report a priority change to high
We were launching the task that watches for the priority change with `high` priority. If the base priority was `medium`, this should immediately report a priority change to `high`. It appears the only reason why this doesn’t happen right now is due to rdar://147868544.
1 parent 374554b commit 250081e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Sources/SwiftExtensions/Task+WithPriorityChangedHandler.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ package func withTaskPriorityChangedHandler<T: Sendable>(
2929
// want to make sure that we don't leave the body task or the priority watching task running.
3030
taskGroup.cancelAll()
3131
}
32-
// Run the task priority watcher with high priority instead of inheriting the initial priority. Otherwise a
33-
// `.background` task might not get its priority elevated because the priority watching task also runs at
34-
// `.background` priority and might not actually get executed in time.
35-
taskGroup.addTask(priority: .high) {
32+
taskGroup.addTask(priority: initialPriority) {
3633
while true {
3734
if Task.isCancelled {
3835
break

0 commit comments

Comments
 (0)