@@ -9,6 +9,9 @@ use crate::utils::errors::SimulationError;
99
1010use sim_derive:: SerializableModel ;
1111
12+ #[ cfg( feature = "simx" ) ]
13+ use simx:: event_rules;
14+
1215/// The load balancer routes jobs to a set of possible process paths, using a
1316/// round robin strategy. There is no stochastic behavior in this model.
1417#[ derive( Debug , Clone , Serialize , Deserialize , SerializableModel ) ]
@@ -61,6 +64,7 @@ enum Phase {
6164 LoadBalancing ,
6265}
6366
67+ #[ cfg_attr( feature = "simx" , event_rules) ]
6468impl LoadBalancer {
6569 pub fn new ( job_port : String , flow_path_ports : Vec < String > , store_records : bool ) -> Self {
6670 Self {
@@ -124,6 +128,7 @@ impl LoadBalancer {
124128 }
125129}
126130
131+ #[ cfg_attr( feature = "simx" , event_rules) ]
127132impl DevsModel for LoadBalancer {
128133 fn events_ext (
129134 & mut self ,
@@ -137,10 +142,9 @@ impl DevsModel for LoadBalancer {
137142 & mut self ,
138143 services : & mut Services ,
139144 ) -> Result < Vec < ModelMessage > , SimulationError > {
140- if self . state . jobs . is_empty ( ) {
141- self . passivate ( )
142- } else {
143- self . send_job ( services)
145+ match self . state . jobs . len ( ) {
146+ 0 => self . passivate ( ) ,
147+ _ => self . send_job ( services) ,
144148 }
145149 }
146150
0 commit comments