[tracks] Safe GpsTrackCollection requests during recording.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako
2025-07-30 15:27:29 -03:00
committed by Konstantin Pastbin
parent fb62982000
commit b7b87f5530
4 changed files with 13 additions and 8 deletions

View File

@@ -50,15 +50,20 @@ void GpsTrack::AddPoints(vector<location::GpsInfo> const & points)
ScheduleTask();
}
TrackStatistics GpsTrack::GetTrackStatistics() const
/// @note These functions are called during recording, so should be synchronized with Collection writer thread.
/// @{
TrackStatistics GpsTrack::GetTrackStatistics()
{
lock_guard<mutex> lg(m_threadGuard);
return m_collection ? m_collection->GetTrackStatistics() : TrackStatistics();
}
ElevationInfo const & GpsTrack::GetElevationInfo() const
ElevationInfo const & GpsTrack::GetElevationInfo()
{
lock_guard<mutex> lg(m_threadGuard);
return m_collection->UpdateAndGetElevationInfo();
}
/// @}
void GpsTrack::Clear()
{