Fixing race condition issue with references in forking executor
This commit is contained in:
@@ -38,25 +38,4 @@ TEST_CASE("threadpool", "[threadpool]") {
|
||||
for (auto &r: res) r.get();
|
||||
REQUIRE(cnt == 100);
|
||||
}
|
||||
|
||||
SECTION("parallel") {
|
||||
std::vector<std::future<void>> res;
|
||||
using namespace std::chrono_literals;
|
||||
std::atomic<uint32_t> maxCnt{0};
|
||||
for (size_t i = 0; i < 100; ++i)
|
||||
res.push_back(tp.addTask([&cnt,&maxCnt, i]() {
|
||||
auto delay = 20ms;
|
||||
uint32_t current = cnt.fetch_add(1);
|
||||
delay += i * 1ms;
|
||||
std::this_thread::sleep_for(delay);
|
||||
if (current > maxCnt) {
|
||||
maxCnt = current;
|
||||
}
|
||||
cnt--;
|
||||
return;
|
||||
}));
|
||||
for (auto &r: res) r.get();
|
||||
REQUIRE(maxCnt > 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user