Fixed Python interpreted not respecting the update rate

This commit is contained in:
Emmanuel Durand
2022-05-13 14:00:12 -04:00
parent 45bac215d5
commit cb82b1dafc
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -1281,7 +1281,7 @@ void PythonEmbedded::loop()
lockAttributes.unlock();
pythonMutexLock.unlock();
Timer::get() >> 1.f / static_cast<float>(_updateRate) * 1000.f >> timerName;
Timer::get() >> 1000000ull / _updateRate >> timerName;
}
pythonMutexLock.lock();
+3 -1
View File
@@ -26,6 +26,7 @@
#define SPLASH_TIMER_H
#include <chrono>
#include <mutex>
#include <string>
#include <thread>
@@ -115,7 +116,7 @@ class Timer
*/
bool waitUntilDuration(const std::string& name, unsigned long long duration)
{
std::lock_guard<Spinlock> lock(_timerMutex);
std::unique_lock<Spinlock> lock(_timerMutex);
if (!_enabled)
return false;
@@ -144,6 +145,7 @@ class Timer
_durationMap[name] = std::max(duration, elapsed);
else
durationIt->second = std::max(duration, elapsed);
lock.unlock();
nanosleep(&nap, NULL);