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

View file

@ -1,16 +1,7 @@
#include "RGBController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
using namespace std::chrono_literals;
RGBController::RGBController()
{
@ -1335,7 +1326,7 @@ void RGBController::DeviceCallThreadFunction()
}
else
{
Sleep(1);
std::this_thread::sleep_for(1ms);
}
}
}

View file

@ -13,6 +13,7 @@
#include <vector>
#include <string>
#include <thread>
#include <chrono>
typedef unsigned int RGBColor;

View file

@ -26,16 +26,7 @@
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
using namespace std::chrono_literals;
THREAD keepalive_thread(void *param)
{
@ -375,6 +366,6 @@ void RGBController_HyperXKeyboard::KeepaliveThread()
UpdateLEDs();
}
}
Sleep(10);
std::this_thread::sleep_for(10ms);;
}
}

View file

@ -12,13 +12,11 @@
#include <fstream>
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
using namespace std::chrono_literals;
void RGBController_OpenRazer::DeviceUpdateLEDs()
{
switch(matrix_type)
{
case RAZER_TYPE_MATRIX_FRAME:
@ -79,7 +77,7 @@ void RGBController_OpenRazer::DeviceUpdateLEDs()
delete[] output_array;
Sleep(1);
std::this_thread::sleep_for(1ms);
}
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
@ -550,7 +548,7 @@ void RGBController_OpenRazer::UpdateMode()
break;
}
Sleep(20);
std::this_thread::sleep_for(20ms);
}
break;

View file

@ -16,6 +16,8 @@
#include <linux/module.h>
#include <linux/hid.h>
using namespace std::chrono_literals;
void RGBController_OpenRazer::DeviceUpdateLEDs()
{
switch(matrix_type)
@ -75,7 +77,7 @@ void RGBController_OpenRazer::DeviceUpdateLEDs()
delete[] output_array;
Sleep(1);
std::this_thread::sleep_for(1ms);
}
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
@ -485,7 +487,7 @@ void RGBController_OpenRazer::UpdateMode()
break;
}
Sleep(20);
std::this_thread::sleep_for(20ms);
}
break;