forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
ae05e4c110
commit
e53bd10437
3 changed files with 28 additions and 11 deletions
|
@ -208,21 +208,24 @@ void Engine::MainLoop(Query & query, queue<TTask> & tasks, queue<TTask> & broadc
|
|||
if (m_shutdown)
|
||||
break;
|
||||
|
||||
TTask task;
|
||||
if (!broadcast.empty())
|
||||
queue<TTask> ts;
|
||||
// Execute all broadcast tasks at once.
|
||||
ts.swap(broadcast);
|
||||
|
||||
if (!tasks.empty())
|
||||
{
|
||||
task = move(broadcast.front());
|
||||
broadcast.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
task = move(tasks.front());
|
||||
// Execute only first task from the common pool.
|
||||
ts.push(move(tasks.front()));
|
||||
tasks.pop();
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
task(query);
|
||||
while (!ts.empty())
|
||||
{
|
||||
ts.front()(query);
|
||||
ts.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,20 @@ void TestSearchRequest::Wait()
|
|||
});
|
||||
}
|
||||
|
||||
steady_clock::duration TestSearchRequest::ResponseTime() const
|
||||
{
|
||||
lock_guard<mutex> lock(m_mu);
|
||||
CHECK(m_done, ("This function may be called only when request is processed."));
|
||||
return m_endTime - m_startTime;
|
||||
}
|
||||
|
||||
vector<search::Result> const & TestSearchRequest::Results() const
|
||||
{
|
||||
lock_guard<mutex> lock(m_mu);
|
||||
CHECK(m_done, ("This function may be called only when request is processed."));
|
||||
return m_results;
|
||||
}
|
||||
|
||||
void TestSearchRequest::OnStarted()
|
||||
{
|
||||
lock_guard<mutex> lock(m_mu);
|
||||
|
|
|
@ -30,8 +30,8 @@ public:
|
|||
void Wait();
|
||||
|
||||
// Call these functions only after call to Wait().
|
||||
inline steady_clock::duration ResponseTime() const { return m_endTime - m_startTime; }
|
||||
inline vector<search::Result> const & Results() const { return m_results; }
|
||||
steady_clock::duration ResponseTime() const;
|
||||
vector<search::Result> const & Results() const;
|
||||
|
||||
private:
|
||||
void OnStarted();
|
||||
|
|
Loading…
Add table
Reference in a new issue