Commit 533b017c authored by Leander Schulten's avatar Leander Schulten

Modules Controller: Use real time diff. The sleep function sleep sometimes longer than it should.

parent 095865eb
Pipeline #271580 passed with stage
in 13 minutes and 34 seconds
......@@ -102,8 +102,14 @@ void Controller::updateSpotifyState(){
}
void Controller::run() noexcept{
using namespace std::chrono;
const auto start = steady_clock::now();
long lastElapsedMilliseconds = 0;
while (run_) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::this_thread::sleep_for(milliseconds(1));
auto elapsedMilliseconds = duration_cast<milliseconds>(steady_clock::now() - start).count();
const auto time_diff = elapsedMilliseconds - lastElapsedMilliseconds;
lastElapsedMilliseconds = elapsedMilliseconds;
if (!run_) {
break;
}
......@@ -111,7 +117,7 @@ void Controller::run() noexcept{
updateSpotifyState();
for(auto pb = runningProgramms.begin() ; pb != runningProgramms.end();){
try {
if ((*pb)->doStep(1)) {
if ((*pb)->doStep(time_diff)) {
deletingProgramBlock = (*pb).get();
(**pb).stop();
deletingProgramBlock = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment