Skip to content

Instantly share code, notes, and snippets.

@qigao
Forked from ngryman/usleep.c
Created January 16, 2017 10:32
Show Gist options
  • Save qigao/abbd30accc8fcdd075f2ab218176f095 to your computer and use it in GitHub Desktop.
Save qigao/abbd30accc8fcdd075f2ab218176f095 to your computer and use it in GitHub Desktop.
usleep for Windows.
void usleep(DWORD waitTime){
LARGE_INTEGER perfCnt, start, now;
QueryPerformanceFrequency(&perfCnt);
QueryPerformanceCounter(&start);
do {
QueryPerformanceCounter((LARGE_INTEGER*) &now);
} while ((now.QuadPart - start.QuadPart) / float(perfCnt.QuadPart) * 1000 * 1000 < waitTime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment