diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-08-31 14:26:21 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:03:26 +0300 |
commit | 1cb07eabec07b2315c8b26dd68566b8d105d867e (patch) | |
tree | 73f085ced04ab23b434bb19312be3d3df591bce0 /routing | |
parent | b375c33e3a313d17e8f1cfe7887c3b26d5853d3f (diff) |
Sinhronization mutex in router delegate.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/router_delegate.cpp | 14 | ||||
-rw-r--r-- | routing/router_delegate.hpp | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/routing/router_delegate.cpp b/routing/router_delegate.cpp index 80784539a4..80c1cac0f0 100644 --- a/routing/router_delegate.cpp +++ b/routing/router_delegate.cpp @@ -24,6 +24,20 @@ void RouterDelegate::SetPointCheckCallback(TPointCheckCallback const & pointCall m_pointCallback = pointCallback ? pointCallback : DefaultPointFn; } +void RouterDelegate::OnProgress(float progress) const +{ + lock_guard<mutex> l(m_guard); + if (!IsCancelled()) + m_progressCallback(progress); +} + +void RouterDelegate::OnPointCheck(m2::PointD const & point) const +{ + lock_guard<mutex> l(m_guard); + if (!IsCancelled()) + m_pointCallback(point); +} + TimeoutCancellable::TimeoutCancellable() : m_timeoutSec(0) { } diff --git a/routing/router_delegate.hpp b/routing/router_delegate.hpp index 42c892ad95..be87acbec4 100644 --- a/routing/router_delegate.hpp +++ b/routing/router_delegate.hpp @@ -6,6 +6,7 @@ #include "base/timer.hpp" #include "std/function.hpp" +#include "std/mutex.hpp" namespace routing { @@ -35,13 +36,16 @@ public: RouterDelegate(); /// Set routing progress. Waits current progress status from 0 to 100. - void OnProgress(float progress) const { if (!IsCancelled()) m_progressCallback(progress); } - void OnPointCheck(m2::PointD const & point) const { if (!IsCancelled()) m_pointCallback(point); } + void OnProgress(float progress) const; + void OnPointCheck(m2::PointD const & point) const; void SetProgressCallback(TProgressCallback const & progressCallback); void SetPointCheckCallback(TPointCheckCallback const & pointCallback); + void Reset() override {lock_guard<mutex> l(m_guard); TimeoutCancellable::Reset();} + private: + mutable mutex m_guard; TProgressCallback m_progressCallback; TPointCheckCallback m_pointCallback; }; |