try compatible with old compilers

This commit is contained in:
mutouyun 2019-01-18 14:59:59 +08:00
parent 44a9a4b98f
commit 88d9f8b225
2 changed files with 4 additions and 4 deletions

View File

@ -115,7 +115,7 @@ void benchmark_prod_cons(T* cq) {
// std::cout << cid << "-consumer-disconnect" << std::endl; // std::cout << cid << "-consumer-disconnect" << std::endl;
// } // }
tcq.disconnect(cn); tcq.disconnect(cn);
if ((fini_c.fetch_add(1, std::memory_order_relaxed) + 1) != std::extent<decltype(consumers)>::value) { if ((fini_c.fetch_add(1, std::memory_order_relaxed) + 1) != M) {
// std::unique_lock<capo::spin_lock> guard { lc }; // std::unique_lock<capo::spin_lock> guard { lc };
// std::cout << cid << "-consumer-end" << std::endl; // std::cout << cid << "-consumer-end" << std::endl;
return; return;
@ -141,7 +141,7 @@ void benchmark_prod_cons(T* cq) {
// } // }
tcq.send(cn, { pid, i }); tcq.send(cn, { pid, i });
} }
if ((fini_p.fetch_add(1, std::memory_order_relaxed) + 1) != std::extent<decltype(producers)>::value) { if ((fini_p.fetch_add(1, std::memory_order_relaxed) + 1) != N) {
return; return;
} }
// quit // quit

View File

@ -265,12 +265,12 @@ void benchmark_lc() {
} }
std::this_thread::yield(); std::this_thread::yield();
} }
if ((fini.fetch_add(1, std::memory_order_relaxed) + 1) == std::extent<decltype(r_trd)>::value) { if ((fini.fetch_add(1, std::memory_order_relaxed) + 1) == R) {
sw.print_elapsed(W, R, Loops); sw.print_elapsed(W, R, Loops);
} }
std::uint64_t sum = 0; std::uint64_t sum = 0;
for (int i : seq) sum += static_cast<std::uint64_t>(i); for (int i : seq) sum += static_cast<std::uint64_t>(i);
QCOMPARE(sum, acc<std::uint64_t>(1, Loops) * std::extent<decltype(w_trd)>::value); QCOMPARE(sum, acc<std::uint64_t>(1, Loops) * W);
}); });
} }