Synchronize map updates with traffic manager

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-08-28 21:10:42 +03:00
parent d46c0fec76
commit ef806cf18a
3 changed files with 60 additions and 48 deletions

View File

@@ -224,6 +224,9 @@ public:
* for these locations are discarded and decoded again, ensuring they are based on the new MWM.
* The TraFF messages themselves remain unchanged.
*
* This method must either be called from a lambda function passed to `RunSynchronized()`,
* or the caller must explicitly lock the private `m_mutex` prior to calling this method.
*
* @param mwmId The newly addded MWM.
*/
void Invalidate(MwmSet::MwmId const & mwmId);
@@ -313,6 +316,19 @@ public:
*/
void SetTrafficUpdateCallbackFn(TrafficUpdateCallbackFn && fn);
/**
* @brief Runs a function guarded by the traffic manager mutex.
*
* This locks `m_mutex`, then runs `f` and releases the mutex.
*
* @param f
*/
void RunSynchronized(std::function<void()> f)
{
std::lock_guard<std::mutex> lock(m_mutex);
f();
}
private:
/**