Skip to content

Instantly share code, notes, and snippets.

@fpersson
Created November 3, 2011 18:14
Show Gist options
  • Save fpersson/1337251 to your computer and use it in GitHub Desktop.
Save fpersson/1337251 to your computer and use it in GitHub Desktop.
a sleep for unix and windows
/**
* @brief Alternerar "sov" funktionen beroende på plattform linux/unix sleep() finns i unistd,
* medan windows (egentilgen DOS) finns i conio.h inget av detta är C++ eller C ANSI standard.
* Funktionen är mest till för att visa hur fjånigt det kan bli i bland.
*
* @warning samma begränsning här med windows/linux och övriga *nix
*/
void doSleep(int timetosleep)
{
#ifdef __linux__
timetosleep = timetosleep/1000;
//tiden i sekunder
sleep(timetosleep);
#else
//tiden i millisekunder
Sleep(timetosleep);
#endif
}
[edit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment