mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Kickr mutex for thread safety
Ensure the member variables are only maintained in one thread at a time.
This commit is contained in:
@@ -100,7 +100,9 @@ double Kickr::getGradient()
|
||||
void
|
||||
Kickr::getRealtimeData(RealtimeData &rtData)
|
||||
{
|
||||
pvars.lock();
|
||||
rtData = rt;
|
||||
pvars.unlock();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -149,12 +151,14 @@ void Kickr::run()
|
||||
msleep(100);
|
||||
|
||||
if (WFApi::getInstance()->hasData()) {
|
||||
pvars.lock();
|
||||
WFApi::getInstance()->getRealtimeData(&rt);
|
||||
|
||||
// set speed from wheelRpm and configured wheelsize
|
||||
double x = rt.getWheelRpm();
|
||||
if (devConf) rt.setSpeed(x * (devConf->wheelSize/1000) * 60 / 1000);
|
||||
else rt.setSpeed(x * 2.10 * 60 / 1000);
|
||||
pvars.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user