diff options
author | vng <viktor.govako@gmail.com> | 2012-10-18 20:54:28 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:45:49 +0300 |
commit | 95e92382d503239bf76e926dce0aec959116a66f (patch) | |
tree | 6d341cb1b3f331ac8dbbe171b046c9126eed2188 /search | |
parent | 8a0210cc2c197fd35387f363aec669e9298365be (diff) |
Emit "end search marker" with cancelled flag. It helps to determine whether the indicator should be shown.
Diffstat (limited to 'search')
-rw-r--r-- | search/result.hpp | 21 | ||||
-rw-r--r-- | search/search_engine.cpp | 6 |
2 files changed, 27 insertions, 0 deletions
diff --git a/search/result.hpp b/search/result.hpp index 697e810c19..6a1326b804 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -57,7 +57,28 @@ class Results { vector<Result> m_vec; + enum StatusT { + NONE, // default status + ENDED_CANCELLED, // search ended with canceling + ENDED // search ended itself + }; + StatusT m_status; + + explicit Results(bool isCancelled) + { + m_status = (isCancelled ? ENDED_CANCELLED : ENDED); + } + public: + Results() : m_status(NONE) {} + + /// @name To implement end of search notification. + //@{ + static Results GetEndMarker(bool isCancelled) { return Results(isCancelled); } + bool IsEndMarker() const { return (m_status != NONE); } + bool IsEndedNormal() const { return (m_status == ENDED); } + //@} + inline void AddResult(Result const & r) { m_vec.push_back(r); } void AddResultCheckExisting(Result const & r); diff --git a/search/search_engine.cpp b/search/search_engine.cpp index 4f7b150382..078c845d04 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -246,6 +246,9 @@ void Engine::SearchAsync() Results res; + // Call m_pQuery->IsCanceled() everywhere it needed without storing return value. + // This flag can be changed from another thread. + try { if (params.m_query.empty()) @@ -291,6 +294,9 @@ void Engine::SearchAsync() if (res.GetCount() > count) params.m_callback(res); } + + // Emit finish marker to client. + params.m_callback(Results::GetEndMarker(m_pQuery->IsCanceled())); } string Engine::GetCountryFile(m2::PointD const & pt) |