Files
comaps/drape_frontend/message_acceptor.hpp
Konstantin Pastbin e3e4a1985a 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
2025-05-08 21:10:51 +07:00

50 lines
1.0 KiB
C++

#pragma once
#include "drape_frontend/message_queue.hpp"
#include "drape/pointers.hpp"
#include <atomic>
#include <mutex>
#include <functional>
namespace df
{
class Message;
class MessageAcceptor
{
protected:
MessageAcceptor();
virtual ~MessageAcceptor() = default;
virtual void AcceptMessage(ref_ptr<Message> message) = 0;
/// Must be called by subclass on message target thread
bool ProcessSingleMessage(bool waitForMessage = true);
void CancelMessageWaiting();
void CloseQueue();
bool IsInInfinityWaiting() const;
#ifdef DEBUG_MESSAGE_QUEUE
bool IsQueueEmpty() const;
size_t GetQueueSize() const;
#endif
void EnableMessageFiltering(MessageQueue::FilterMessageFn && filter);
void DisableMessageFiltering();
void InstantMessageFilter(MessageQueue::FilterMessageFn && filter);
private:
friend class ThreadsCommutator;
void PostMessage(drape_ptr<Message> && message, MessagePriority priority);
MessageQueue m_messageQueue;
std::atomic<bool> m_infinityWaiting;
};
} // namespace df