CityScope / CS_Simulation_GAMA

Agent Based Simulation platform for CityScope
GNU General Public License v3.0
31 stars 21 forks source link

Too many gets when idle #152

Closed crisjf closed 4 years ago

crisjf commented 4 years ago

Documenting solved issue.

When idle, this block of code was generating an insane amount of get requests:

            do pause;
            idle_step_start<-machine_time/1000;
            loop while: (idle_mode) {
                string new_grid_hash_id <- get_grid_hash();
                if ((new_grid_hash_id != grid_hash_id))  {
                    idle_mode<-false;
                }
            }
            do resume;

The solution was to define idle_update_frequency and use machine_time to have control over the update frequency

            do pause;
            idle_step_start<-machine_time/1000;
            loop while: (idle_mode) {
                if (machine_time/1000>=idle_step_start+idle_update_frequency) {
                    string new_grid_hash_id <- get_grid_hash();
                    if ((new_grid_hash_id != grid_hash_id))  {
                        idle_mode<-false;
                    }
                    idle_step_start<-machine_time/1000;
                }
            }
            do resume;