[drape] only one UpdateReadManagerMessage at moment

This commit is contained in:
ExMix 2015-11-29 13:31:05 +03:00 committed by r.kuznetsov
parent 0a6337bb2a
commit 06f54b1477
4 changed files with 30 additions and 8 deletions

View file

@ -168,7 +168,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
m_requestedTiles->Set(screen, move(tiles));
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
make_unique_dp<UpdateReadManagerMessage>(),
MessagePriority::Normal);
MessagePriority::UberHighSingleton);
}
break;
}
@ -427,7 +427,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
m_requestedTiles->Set(screen, move(tiles));
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
make_unique_dp<UpdateReadManagerMessage>(),
MessagePriority::Normal);
MessagePriority::UberHighSingleton);
RefreshBgColor();
@ -1059,7 +1059,7 @@ void FrontendRenderer::UpdateScene(ScreenBase const & modelView)
m_requestedTiles->Set(modelView, move(tiles));
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
make_unique_dp<UpdateReadManagerMessage>(),
MessagePriority::High);
MessagePriority::UberHighSingleton);
}
void FrontendRenderer::EmitModelViewChanged(ScreenBase const & modelView) const

View file

@ -52,7 +52,8 @@ public:
enum class MessagePriority
{
Normal,
High
High,
UberHighSingleton
};
} // namespace df

View file

@ -32,7 +32,7 @@ drape_ptr<Message> MessageQueue::PopMessage(bool waitForMessage)
if (m_messages.empty())
return nullptr;
drape_ptr<Message> msg = move(m_messages.front());
drape_ptr<Message> msg = move(m_messages.front().first);
m_messages.pop_front();
return msg;
}
@ -45,12 +45,32 @@ void MessageQueue::PushMessage(drape_ptr<Message> && message, MessagePriority pr
{
case MessagePriority::Normal:
{
m_messages.emplace_back(move(message));
m_messages.emplace_back(move(message), priority);
break;
}
case MessagePriority::High:
{
m_messages.emplace_front(move(message));
auto iter = m_messages.begin();
while (iter != m_messages.end() && iter->second > MessagePriority::High) { iter++; }
m_messages.emplace(iter, move(message), priority);
break;
}
case MessagePriority::UberHighSingleton:
{
bool found = false;
auto iter = m_messages.begin();
while (iter != m_messages.end() && iter->second == MessagePriority::UberHighSingleton)
{
if (iter->first->GetType() == message->GetType())
{
found = true;
break;
}
iter++;
}
if (!found)
m_messages.emplace_front(move(message), priority);
break;
}
default:

View file

@ -38,7 +38,8 @@ private:
mutable mutex m_mutex;
condition_variable m_condition;
bool m_isWaiting;
deque<drape_ptr<Message> > m_messages;
using TMessageNode = pair<drape_ptr<Message>, MessagePriority>;
deque<TMessageNode> m_messages;
};
} // namespace df