Its maybe not a race condition?

This commit is contained in:
Dynamitos
2023-12-18 13:03:03 +01:00
parent 617bb2828d
commit ac1d11402e
2 changed files with 4 additions and 4 deletions
+3 -4
View File
@@ -7,15 +7,14 @@ TEST(ThreadPool, RunBatch)
ThreadPool t(10);
uint32 test = 20;
std::mutex m;
List<Task> work;
List<std::function<void()>> work;
for (uint32 i = 0; i < 400; ++i)
{
work.add([&]() -> Task {
work.add([&]() {
std::unique_lock l(m);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
test++;
co_return;
}());
});
}
t.runAndWait(std::move(work));
ASSERT_EQ(test, 420);