Skip to content

Commit 301bca1

Browse files
committed
waitQueue.compare_exchange_strong in the true loop can be weak
weak is more suitable for this while loop than strong.
1 parent f08f86c commit 301bca1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ reevaluate_if_taskgroup_has_results:;
17861786
}
17871787
// Put the waiting task at the beginning of the wait queue.
17881788
SWIFT_TASK_GROUP_DEBUG_LOG(this, "WATCH OUT, SET WAITER ONTO waitQueue.head = %p", waitQueue.load(std::memory_order_relaxed));
1789-
if (waitQueue.compare_exchange_strong(
1789+
if (waitQueue.compare_exchange_weak(
17901790
waitHead, waitingTask,
17911791
/*success*/ std::memory_order_release,
17921792
/*failure*/ std::memory_order_acquire)) {
@@ -1947,7 +1947,7 @@ void TaskGroupBase::waitAll(SwiftError* bodyError, AsyncTask *waitingTask,
19471947
waitingTask->flagAsSuspendedOnTaskGroup(asAbstract(this));
19481948
}
19491949
// Put the waiting task at the beginning of the wait queue.
1950-
if (waitQueue.compare_exchange_strong(
1950+
if (waitQueue.compare_exchange_weak(
19511951
waitHead, waitingTask,
19521952
/*success*/ std::memory_order_release,
19531953
/*failure*/ std::memory_order_acquire)) {

0 commit comments

Comments
 (0)