mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
49
drape_frontend/message_queue.hpp
Normal file
49
drape_frontend/message_queue.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape_frontend/message.hpp"
|
||||
|
||||
#include "drape/drape_diagnostics.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
||||
namespace df
|
||||
{
|
||||
class MessageQueue
|
||||
{
|
||||
public:
|
||||
MessageQueue();
|
||||
~MessageQueue();
|
||||
|
||||
// If the queue is empty then it returns nullptr or wait for a message.
|
||||
drape_ptr<Message> PopMessage(bool waitForMessage);
|
||||
void PushMessage(drape_ptr<Message> && message, MessagePriority priority);
|
||||
void CancelWait();
|
||||
void ClearQuery();
|
||||
|
||||
using FilterMessageFn = std::function<bool(ref_ptr<Message>)>;
|
||||
void EnableMessageFiltering(FilterMessageFn && filter);
|
||||
void DisableMessageFiltering();
|
||||
void InstantFilter(FilterMessageFn && filter);
|
||||
|
||||
#ifdef DEBUG_MESSAGE_QUEUE
|
||||
bool IsEmpty() const;
|
||||
size_t GetSize() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void FilterMessagesImpl();
|
||||
void CancelWaitImpl();
|
||||
|
||||
mutable std::mutex m_mutex;
|
||||
std::condition_variable m_condition;
|
||||
bool m_isWaiting;
|
||||
using TMessageNode = std::pair<drape_ptr<Message>, MessagePriority>;
|
||||
std::deque<TMessageNode> m_messages;
|
||||
std::deque<drape_ptr<Message>> m_lowPriorityMessages;
|
||||
FilterMessageFn m_filter;
|
||||
};
|
||||
} // namespace df
|
||||
Reference in New Issue
Block a user