lundi 17 août 2020

Restructuring Infinite loop with Arrow Code

I have an infinite loop with certain period (delay). I have the following structure:

// define the i32threshold of time
// set i32counter to 0
while(true)
{
  if(bExecuteEnable)
  {
    if(bConnectionSet)
    {
      if(++i32counter >= i32threshold)
      {
        // Do the job
        counter = 0;
      }
    }
  }

  delay(1); // 1 ms of delay introduces the period
}

Do you have any recommendation to restructure this infinite loop other than having all conditions merged into single ifstatement?

Aucun commentaire:

Enregistrer un commentaire