1- #ifndef  LOAD_BALANCER_HH //  NOLINT
2- #define  LOAD_BALANCER_HH  //  NOLINT
1+ /* 
2+  * Copyright (C) 2025 TU Dresden 
3+  * All rights reserved. 
4+  * 
5+  * Authors: 
6+  *   Tassilo Tanneberger 
7+  */  
38
4- #include  < reactor-cpp/reactor-cpp.hh> 
9+ #ifndef  MULTIPORT_MUTATION_LOAD_BALANCER_HH //  NOLINT
10+ #define  MULTIPORT_MUTATION_LOAD_BALANCER_HH  //  NOLINT
511
6- #include  " reactor-cpp/mutations/multiport.hh" 
12+ #include  < reactor-cpp/mutations/multiport.hh> 
13+ #include  < reactor-cpp/reactor-cpp.hh> 
714
815using  namespace  reactor ; 
916using  namespace  std ::chrono_literals; 
@@ -19,24 +26,21 @@ class LoadBalancer final : public Reactor { // NOLINT
1926      if  (std::rand () % 15  == 0 ) {            //  NOLINT
2027        scale_bank.set (std::rand () % 20  + 1 ); //  NOLINT
2128      }
22-       const  unsigned  sel = std::rand () % outbound.size (); //  NOLINT
23-       //  std::cout << "Sending out to:" << sel << '\n';
24-       outbound[sel].set (inbound.get ());
25-       outbound[std::min (4ul , outbound.size () - 1 )].set (inbound.get ());
29+       const  unsigned  outbound_port = std::rand () % outbound.size (); //  NOLINT
30+       outbound[outbound_port].set (inbound.get ());
2631    }
2732
2833    friend  LoadBalancer;
2934  };
3035
3136  Inner _lf_inner;
32-   Reaction process{" process"  , 2 , this , [this ]() { Inner::reaction_1 (this ->inbound , this ->scale_bank , this ->out ); }};
37+   Reaction process{" process"  , 1 , this , [this ]() { Inner::reaction_1 (this ->inbound , this ->scale_bank , this ->out ); }};
3338
3439public: 
3540  LoadBalancer (const  std::string& name, Environment* env)
3641      : Reactor(name, env)
3742      , _lf_inner(this ) {
3843    out.reserve (4 );
39-     std::cout << " creating instance of load balancer"   << ' \n '  ;
4044    for  (size_t  _lf_idx = 0 ; _lf_idx < 4 ; _lf_idx++) {
4145      out.create_new_port ();
4246    }
@@ -45,16 +49,16 @@ public:
4549
4650  ModifableMultiport<Output<unsigned >> out{" out"  , this }; //  NOLINT
4751  std::size_t  out_size_ = 0 ;
52+ 
4853  Input<unsigned > inbound{" inbound"  , this };        //  NOLINT
4954  Output<unsigned > scale_bank{" scale_bank"  , this }; //  NOLINT
5055
5156  void  assemble () override  {
52-     std::cout << " assemble LoadBalancer\n "  ;
5357    for  (auto & _lf_port : out) {
5458      process.declare_antidependency (&_lf_port);
5559    }
5660    process.declare_trigger (&inbound);
5761  }
5862};
5963
60- #endif  //  LOAD_BALANCER_HH 
64+ #endif  //  MULTIPORT_MUTATION_LOAD_BALANCER_HH 
0 commit comments