blob: db070f5790aff323f9b1176c218bd618bce08548 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "drape_frontend/message_acceptor.hpp"
#include "drape_frontend/message.hpp"
namespace df
{
MessageAcceptor::MessageAcceptor()
: m_infinityWaiting(false)
{
}
bool MessageAcceptor::ProcessSingleMessage(bool waitForMessage)
{
m_infinityWaiting = waitForMessage;
drape_ptr<Message> message = m_messageQueue.PopMessage(waitForMessage);
m_infinityWaiting = false;
if (message == nullptr)
return false;
AcceptMessage(make_ref(message));
return true;
}
void MessageAcceptor::EnableMessageFiltering(TFilterMessageFn needFilterMessageFn)
{
m_needFilterMessageFn = needFilterMessageFn;
m_messageQueue.FilterMessages(needFilterMessageFn);
}
void MessageAcceptor::DisableMessageFiltering()
{
m_needFilterMessageFn = nullptr;
}
void MessageAcceptor::PostMessage(drape_ptr<Message> && message, MessagePriority priority)
{
if (m_needFilterMessageFn != nullptr && m_needFilterMessageFn(make_ref(message)))
return;
m_messageQueue.PushMessage(move(message), priority);
}
void MessageAcceptor::CloseQueue()
{
m_messageQueue.CancelWait();
m_messageQueue.ClearQuery();
}
void MessageAcceptor::CancelMessageWaiting()
{
m_messageQueue.CancelWait();
}
bool MessageAcceptor::IsInInfinityWaiting() const
{
return m_infinityWaiting;
}
#ifdef DEBUG_MESSAGE_QUEUE
bool MessageAcceptor::IsQueueEmpty() const
{
return m_messageQueue.IsEmpty();
}
size_t MessageAcceptor::GetQueueSize() const
{
return m_messageQueue.GetSize();
}
#endif
} // namespace df
|