Skip to content

Commit bbfd9d5

Browse files
committed
Error handling not relying on exceptions
1 parent 08eedaa commit bbfd9d5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

relaxed_concurrent_fifo/benchmark.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ struct benchmark_bfs : benchmark_timed<> {
291291
long long pushed_nodes{ 0 };
292292
long long ignored_nodes{ 0 };
293293
long long processed_nodes{ 0 };
294+
bool err{ false };
294295
};
295296

296297
#ifdef __GNUC__
@@ -331,7 +332,7 @@ struct benchmark_bfs : benchmark_timed<> {
331332
while (d < old_d) {
332333
if (distances[target].value.compare_exchange_weak(old_d, d, std::memory_order_relaxed)) {
333334
if (!handle.push((static_cast<std::uint64_t>(d) << 32) | target)) {
334-
throw std::runtime_error("Push failed!");
335+
counter.err = true;
335336
}
336337
++counter.pushed_nodes;
337338
break;
@@ -368,9 +369,15 @@ struct benchmark_bfs : benchmark_timed<> {
368369
sum.pushed_nodes += counter.pushed_nodes;
369370
sum.processed_nodes += counter.processed_nodes;
370371
sum.ignored_nodes += counter.ignored_nodes;
372+
sum.err |= counter.err;
371373
return sum;
372374
});
373375

376+
if (total_counts.err) {
377+
stream << "ERR";
378+
return;
379+
}
380+
374381
auto longest_distance =
375382
std::max_element(distances.begin(), distances.end(), [](auto const& a, auto const& b) {
376383
auto a_val = a.value.load(std::memory_order_relaxed);

0 commit comments

Comments
 (0)