Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
Diffstat (limited to 'search')
-rw-r--r--search/result.hpp21
-rw-r--r--search/search_engine.cpp6
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)