Fix bug in swap_test iteration logic that caused early termination of the swap loop

This commit is contained in:
Christian Mazakas
2023-05-02 15:57:16 -07:00
parent a9bf367d6e
commit cc4cfc7ef2

View File

@ -191,7 +191,6 @@ namespace {
if (idx % 100 == 0) { if (idx % 100 == 0) {
cv.notify_all(); cv.notify_all();
} }
std::this_thread::yield();
} }
done1 = true; done1 = true;
@ -202,7 +201,6 @@ namespace {
for (auto const& val : vals2) { for (auto const& val : vals2) {
x2.insert(val); x2.insert(val);
std::this_thread::yield();
} }
done2 = true; done2 = true;
@ -216,8 +214,7 @@ namespace {
} }
x1.swap(x2); x1.swap(x2);
++num_swaps; ++num_swaps;
std::this_thread::yield(); } while (!done1 || !done2);
} while (!done1 && !done2);
}); });
t1.join(); t1.join();