Added platform independent sleep function

This commit is contained in:
Matt Hill
2014-08-19 00:41:45 -04:00
parent 14579a2227
commit 5612f790a0
3 changed files with 25 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ set(support_source_files
filesystem.cpp filesystem.cpp
timing.cpp timing.cpp
tinythread.cpp tinythread.cpp
platform.cpp
) )
add_library(support STATIC ${support_source_files}) add_library(support STATIC ${support_source_files})

View File

@@ -0,0 +1,10 @@
#include "platform.h"
void sleep_ms(int sleepMs)
{
#ifdef WINDOWS
Sleep(sleepMs);
#else
usleep(sleepMs * 1000); // usleep takes sleep time in us (1 millionth of a second)
#endif
}

View File

@@ -0,0 +1,14 @@
#ifndef OPENALPR_PLATFORM_H
#define OPENALPR_PLATFORM_H
#ifdef WINDOWS
#include <windows.h>
#else
#include <unistd.h>
#endif
void sleep_ms(int sleepMs);
#endif //OPENALPR_PLATFORM_H