diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2014-04-16 12:16:00 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:14:54 +0300 |
commit | 57b8fc50eca8c55f9cf9b4d08156ee7bfa22bd35 (patch) | |
tree | a29c45d8a5480efbbfae5de40a0fd7a44f696559 /drape_frontend/message_queue.cpp | |
parent | f702a3820ad10b1213c1793239ebcdff04e77731 (diff) |
[drape] bring code to the standard form
Diffstat (limited to 'drape_frontend/message_queue.cpp')
-rw-r--r-- | drape_frontend/message_queue.cpp | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/drape_frontend/message_queue.cpp b/drape_frontend/message_queue.cpp index 1867a20a08..eaef5ece32 100644 --- a/drape_frontend/message_queue.cpp +++ b/drape_frontend/message_queue.cpp @@ -5,52 +5,54 @@ namespace df { - MessageQueue::~MessageQueue() - { - CancelWait(); - ClearQuery(); - } - - TransferPointer<Message> MessageQueue::PopMessage(unsigned maxTimeWait) - { - threads::ConditionGuard guard(m_condition); - - WaitMessage(maxTimeWait); - - /// even waitNonEmpty == true m_messages can be empty after WaitMessage call - /// if application preparing to close and CancelWait been called - if (m_messages.empty()) - return MovePointer<Message>(NULL); - - MasterPointer<Message> msg = m_messages.front(); - m_messages.pop_front(); - return msg.Move(); - } - - void MessageQueue::PushMessage(TransferPointer<Message> message) - { - threads::ConditionGuard guard(m_condition); - - bool wasEmpty = m_messages.empty(); - m_messages.push_back(MasterPointer<Message>(message)); - - if (wasEmpty) - guard.Signal(); - } - - void MessageQueue::WaitMessage(unsigned maxTimeWait) - { - if (m_messages.empty()) - m_condition.Wait(maxTimeWait); - } - - void MessageQueue::CancelWait() - { - m_condition.Signal(); - } - - void MessageQueue::ClearQuery() - { - GetRangeDeletor(m_messages, MasterPointerDeleter())(); - } + +MessageQueue::~MessageQueue() +{ + CancelWait(); + ClearQuery(); +} + +TransferPointer<Message> MessageQueue::PopMessage(unsigned maxTimeWait) +{ + threads::ConditionGuard guard(m_condition); + + WaitMessage(maxTimeWait); + + /// even waitNonEmpty == true m_messages can be empty after WaitMessage call + /// if application preparing to close and CancelWait been called + if (m_messages.empty()) + return MovePointer<Message>(NULL); + + MasterPointer<Message> msg = m_messages.front(); + m_messages.pop_front(); + return msg.Move(); } + +void MessageQueue::PushMessage(TransferPointer<Message> message) +{ + threads::ConditionGuard guard(m_condition); + + bool wasEmpty = m_messages.empty(); + m_messages.push_back(MasterPointer<Message>(message)); + + if (wasEmpty) + guard.Signal(); +} + +void MessageQueue::WaitMessage(unsigned maxTimeWait) +{ + if (m_messages.empty()) + m_condition.Wait(maxTimeWait); +} + +void MessageQueue::CancelWait() +{ + m_condition.Signal(); +} + +void MessageQueue::ClearQuery() +{ + (void)GetRangeDeletor(m_messages, MasterPointerDeleter())(); +} + +} // namespace df |