Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -270,10 +270,10 @@ public: · 269 unmodified lines | ||
| 270 | 270 | void run() override { |
| 271 | 271 | while (!_quit) { |
| 272 | 272 | QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS); |
| 273 | − auto now = usecTimestampNow(); | |
| 274 | 273 | |
| 275 | − // in the unlikely event that now is less than _heartbeat, don't rollover and confuse ourselves | |
| 276 | − auto lastHeartbeatAge = (now > _heartbeat) ? now - _heartbeat : 0; | |
| 274 | + uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us | |
| 275 | + uint64_t now = usecTimestampNow(); | |
| 276 | + auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0; | |
| 277 | 277 | auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0; |
| 278 | 278 | auto elapsedMovingAverage = _movingAverage.getAverage(); |
| 279 | 279 | |
| @@ -310,7 +310,7 @@ public: · 30 unmodified lines | ||
| 310 | 310 | if (lastHeartbeatAge > MAX_HEARTBEAT_AGE_USECS) { |
| 311 | 311 | qDebug() << "DEADLOCK DETECTED -- " |
| 312 | 312 | << "lastHeartbeatAge:" << lastHeartbeatAge |
| 313 | − << "[ _heartbeat:" << _heartbeat | |
| 313 | + << "[ lastHeartbeat :" << lastHeartbeat | |
| 314 | 314 | << "now:" << now << " ]" |
| 315 | 315 | << "elapsedMovingAverage:" << elapsedMovingAverage |
| 316 | 316 | << "maxElapsed:" << _maxElapsed |