Everybody knows that you should never use "goto" statements. Well, except in one or two rare circumstances that you won't come across anyway. But even when you do come across those situations, they're usually "mirage cases" where there's no need to "goto" anyway. Kinda like today's example, written by Jonathan Rockway's colleague. Of course, the irony here is that the author likely tried to use "continue" as his label, but was forced to abbreviate it to "cont" in order to skirt compiler "reserved words" errors.

while( sysmgr->getProcessCount() != 0 )
{
  // Yes, I realize "goto" statements are considered harmful,
  // but this is a case where it is OK to use them
  cont:

  //inactivation is not guaranteed and may take up to 3 calls
  sysmgr->CurrentProcess()->TryInactivate();
  
  if( sysmgr->CurrentProcess()->IsActive() )
  {
    Sleep(DEFAULT_TIMEOUT);
    goto cont;
  }

  /* ED: Snip */

  //disconnect child processes
  if( sysmgr->CurrentProcess()->HasChildProcesses() )
  {
    /* ED: Snip */
  }

  /* ED: Snip */
   
  if( sysmgr->CurrentProcess()->IsReusable() )
  {
    sysmgr->ReuseCurrentProcess();
    goto cont;
  }  

  sysmgr->CloseCurrentProcess();

}

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!