do not sleep less than 1ms (#82)

This commit is contained in:
WarmUpTill 2020-12-13 17:26:59 +01:00 committed by GitHub
parent faca5f8863
commit 07b95cb8ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -354,8 +354,11 @@ void SwitcherData::Thread()
} else {
duration =
std::chrono::milliseconds(interval) - runTime;
if (duration.count() < 0)
duration = std::chrono::milliseconds(0);
if (duration.count() < 1) {
blog(LOG_INFO,
"detected busy loop - refusing to sleep less than 1ms");
duration = std::chrono::milliseconds(50);
}
}
//sleep for a bit