Replace Sleep() by std:🧵:sleep_for()

This commit is contained in:
Térence Clastres 2020-06-20 15:50:07 +02:00 committed by Adam Honse
parent 60baf6d05f
commit b79ff124e6
24 changed files with 80 additions and 232 deletions

28
cli.cpp
View file

@ -9,29 +9,15 @@
#include "i2c_smbus.h"
#include "NetworkServer.h"
/*-------------------------------------------------------------*\
| Quirk for MSVC; which doesn't support this case-insensitive |
| function |
\*-------------------------------------------------------------*/
#ifdef _WIN32
#include <Windows.h>
/* swy: quirk for MSVC; which doesn't support this case-insensitive function */
#define strcasecmp strcmpi
#define strcasecmp strcmpi
#endif
#ifdef __APPLE__
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
#ifdef __linux__
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
using namespace std::chrono_literals;
static std::vector<RGBController*> rgb_controllers;
static ProfileManager* profile_manager;
@ -943,7 +929,7 @@ void WaitWhileServerOnline(NetworkServer* srv)
{
while (network_server->GetOnline())
{
Sleep(1000);
std::this_thread::sleep_for(1s);
};
}