Update test to spin until the container is non-empty

This commit is contained in:
Christian Mazakas
2023-04-21 10:44:06 -07:00
parent 88d4d64edf
commit 2cf72093b1

View File

@ -534,22 +534,25 @@ namespace {
{ {
map_type x(0, hasher(1), key_equal(2), allocator_type{}); map_type x(0, hasher(1), key_equal(2), allocator_type{});
auto f = [&x, &values, &m, &cv, &ready] { std::atomic_uint num_transfers{0};
std::thread t1([&x, &values] {
for (auto const& val : values) {
x.insert(val);
}
});
std::thread t2([&x, &m, &cv, &ready] {
while (x.empty()) {
std::this_thread::yield();
}
{ {
std::lock_guard<std::mutex> guard(m); std::lock_guard<std::mutex> guard(m);
ready = true; ready = true;
} }
cv.notify_all(); cv.notify_all();
});
for (auto const& val : values) {
x.insert(val);
}
};
std::atomic_uint num_transfers{0};
std::thread t1(f);
std::thread t2(f);
thread_runner( thread_runner(
values, [&x, &reference_map, &num_transfers, rg, &m, &ready, &cv]( values, [&x, &reference_map, &num_transfers, rg, &m, &ready, &cv](