Skip to content

Commit a41f1b0

Browse files
authored
Merge pull request #40252 from kavon/main-taskgroup-bug
2 parents 4440bd4 + 69e80a1 commit a41f1b0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,14 @@ class TaskGroupImpl: public TaskGroupTaskStatusRecord {
395395
///
396396
/// This is used to atomically perform a waiting task completion.
397397
bool statusCompletePendingReadyWaiting(GroupStatus &old) {
398-
return status.compare_exchange_weak(
398+
return status.compare_exchange_strong(
399399
old.status, old.completingPendingReadyWaiting().status,
400400
/*success*/ std::memory_order_relaxed,
401401
/*failure*/ std::memory_order_relaxed);
402402
}
403403

404404
bool statusCompletePendingReady(GroupStatus &old) {
405-
return status.compare_exchange_weak(
405+
return status.compare_exchange_strong(
406406
old.status, old.completingPendingReady().status,
407407
/*success*/ std::memory_order_relaxed,
408408
/*failure*/ std::memory_order_relaxed);
@@ -589,7 +589,7 @@ void TaskGroupImpl::offer(AsyncTask *completedTask, AsyncContext *context) {
589589
assert(assumed.pendingTasks() && "offered to group with no pending tasks!");
590590
// We are the "first" completed task to arrive,
591591
// and since there is a task waiting we immediately claim and complete it.
592-
if (waitQueue.compare_exchange_weak(
592+
if (waitQueue.compare_exchange_strong(
593593
waitingTask, nullptr,
594594
/*success*/ std::memory_order_release,
595595
/*failure*/ std::memory_order_acquire) &&
@@ -756,7 +756,7 @@ PollResult TaskGroupImpl::poll(AsyncTask *waitingTask) {
756756

757757
auto assumedStatus = assumed.status;
758758
auto newStatus = TaskGroupImpl::GroupStatus{assumedStatus};
759-
if (status.compare_exchange_weak(
759+
if (status.compare_exchange_strong(
760760
assumedStatus, newStatus.completingPendingReadyWaiting().status,
761761
/*success*/ std::memory_order_relaxed,
762762
/*failure*/ std::memory_order_acquire)) {
@@ -822,7 +822,7 @@ PollResult TaskGroupImpl::poll(AsyncTask *waitingTask) {
822822
waitingTask->flagAsSuspended();
823823
}
824824
// Put the waiting task at the beginning of the wait queue.
825-
if (waitQueue.compare_exchange_weak(
825+
if (waitQueue.compare_exchange_strong(
826826
waitHead, waitingTask,
827827
/*success*/ std::memory_order_release,
828828
/*failure*/ std::memory_order_acquire)) {

0 commit comments

Comments
 (0)