Skip to content

Commit 433ff59

Browse files
authored
Merge pull request swiftlang#80319 from mikeash/priority-escalation-retry-fix
[Concurrency] Avoid de-escalating a task when racing to escalate.
2 parents 1732a4d + 7c3b06d commit 433ff59

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

stdlib/public/Concurrency/TaskStatus.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,9 @@ static swift_task_escalateImpl(AsyncTask *task, JobPriority newPriority) {
11391139
auto newStatus = oldStatus;
11401140

11411141
while (true) {
1142+
// Ensure oldPriority is up to date if we retry the compare_exchange.
1143+
oldPriority = oldStatus.getStoredPriority();
1144+
11421145
// Fast path: check that the stored priority is already at least
11431146
// as high as the desired priority.
11441147
if (oldPriority >= newPriority) {

0 commit comments

Comments
 (0)