Fixed bug when generating identical fanouts

This commit is contained in:
2026-05-09 08:36:51 +02:00
parent 2bca2a7554
commit 9ce581b5ce
5 changed files with 366 additions and 11 deletions
+6 -6
View File
@@ -44,7 +44,7 @@ using repeat_tuple_t = typename repeat_tuple<T, N>::type;
// .connect("fan", fan.output<0>(), "nodeA", nodeA.input<0>())
// .connect("fan", fan.output<1>(), "nodeB", nodeB.input<0>())
template<typename T, std::size_t N>
template<typename T, std::size_t N, std::size_t Id = 0>
class FanoutNode : public INode {
public:
using args_tuple = std::tuple<T>;
@@ -141,8 +141,10 @@ private:
auto cpu0 = NodeStats::cpu_now();
for (std::size_t i = 0; i < N; ++i) {
if (out_channels_[i])
out_channels_[i]->push(val);
if (out_channels_[i]) {
try { out_channels_[i]->push(val); }
catch (const ChannelOverflowError&) {} // drop for this output independently
}
}
auto cpu1 = NodeStats::cpu_now();
@@ -150,8 +152,6 @@ private:
stats_.record_exec(duration_t(t2 - t1), duration_t(t1 - t0), cpu0, cpu1);
} catch (const ChannelClosedError&) {
break;
} catch (const ChannelOverflowError& e) {
std::cerr << "[kpn] fanout overflow: " << e.what() << "\n";
}
}
}
@@ -169,7 +169,7 @@ private:
template<typename T, std::size_t N>
FanoutNode<T, N> make_fanout(std::size_t fifo_capacity = 5) {
return FanoutNode<T, N>(fifo_capacity);
return FanoutNode<T, N, 0>(fifo_capacity);
}
} // namespace kpn