You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The shape of this API is similar to the `withTaskCancellationHandler` API present since initial Swift Concurrency release, however–unlike a cancellation handler–the `onPriorityEscalated` callback may be triggered multiple times. The `TaskPriority` passed to the handleris the "new priority" the surrounding task was escalated to.
131
+
The shape of this API is similar to the `withTaskCancellationHandler` API present since initial Swift Concurrency release, however–unlike a cancellation handler–the `onPriorityEscalated` callback may be triggered multiple times. There are two `TaskPriority`arguments passed to the handler. The first argument is the "old" priority, from before the task priority was escalated, and the second argument is the new escalated-to task priority.
132
132
133
133
It is guaranteed that priority is ever only increasing, as Swift Concurrency does not allow for a task priority to ever be lowered after it has been escalated. If attempts are made to escalate the task priority from multiple other threads to the same priority, the handler will only trigger once. However if priority is escalated to a high and then even higher priority, the handler may be invoked twice.
134
134
@@ -139,7 +139,7 @@ Task escalation handlers are inherently racy, and may sometimes miss an escalati
139
139
// priority: high!
140
140
awaitwithTaskPriorityEscalationHandler {
141
141
awaitwork()
142
-
} onPriorityEscalated: { newPriority in// may not be triggered if ->high escalation happened before handler was installed
142
+
} onPriorityEscalated: { oldPriority, newPriority in// may not be triggered if ->high escalation happened before handler was installed
0 commit comments