Fixed bug when generating identical fanouts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -116,7 +116,7 @@ struct FanoutPlaceholder {
|
||||
|
||||
namespace kpn {
|
||||
// Forward declaration — FanoutNode is defined in fanout.hpp.
|
||||
template<typename T, std::size_t N> class FanoutNode;
|
||||
template<typename T, std::size_t N, std::size_t Id> class FanoutNode;
|
||||
} // namespace kpn
|
||||
|
||||
namespace kpn::tmp {
|
||||
@@ -172,7 +172,7 @@ template<std::size_t FanoutId, typename T, std::size_t N,
|
||||
typename DstNodeT, std::size_t DstI, typename... DstTail, std::size_t I>
|
||||
struct fanout_to_dst_edges<FanoutId, T, N,
|
||||
TypeList<DstDesc<DstNodeT, DstI>, DstTail...>, I> {
|
||||
using head_edge = SimpleEdge<kpn::FanoutNode<T, N>, I, DstNodeT, DstI>;
|
||||
using head_edge = SimpleEdge<kpn::FanoutNode<T, N, FanoutId>, I, DstNodeT, DstI>;
|
||||
using rest = typename fanout_to_dst_edges<FanoutId, T, N,
|
||||
TypeList<DstTail...>, I+1>::type;
|
||||
using type = append_t<rest, head_edge>;
|
||||
@@ -282,7 +282,7 @@ struct process_edge {
|
||||
using DstDescs = typename collect_dsts<Port, AllEdges>::type;
|
||||
static constexpr std::size_t fid = State::next_id;
|
||||
using fanout_type = FanoutPlaceholder<T, N, fid>;
|
||||
using src_to_fan = SimpleEdge<SrcNode, Edge::src_idx, FanoutNode<T, N>, 0>;
|
||||
using src_to_fan = SimpleEdge<SrcNode, Edge::src_idx, FanoutNode<T, N, fid>, 0>;
|
||||
using fan_to_dsts = typename fanout_to_dst_edges<fid, T, N, DstDescs>::type;
|
||||
using fanout_edges = concat_t<append_t<typename State::edges, src_to_fan>, fan_to_dsts>;
|
||||
using new_fanouts = append_t<typename State::fanouts, fanout_type>;
|
||||
@@ -340,10 +340,9 @@ struct to_fanout_tuple<TypeList<>> { using type = std::tuple<>; };
|
||||
template<typename T, std::size_t N, std::size_t Id, typename... Rest>
|
||||
struct to_fanout_tuple<TypeList<FanoutPlaceholder<T, N, Id>, Rest...>> {
|
||||
using rest = typename to_fanout_tuple<TypeList<Rest...>>::type;
|
||||
// prepend FanoutNode<T,N>
|
||||
template<typename Tuple> struct prepend;
|
||||
template<typename... Ts> struct prepend<std::tuple<Ts...>> {
|
||||
using type = std::tuple<kpn::FanoutNode<T, N>, Ts...>;
|
||||
using type = std::tuple<kpn::FanoutNode<T, N, Id>, Ts...>;
|
||||
};
|
||||
using type = typename prepend<rest>::type;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user