6 #include "MessageQueue.h"
13 template <
typename TMessage,
typename TDispatcher>
23 : m_messageQueue(messageQueue)
29 void SendMessage(TMessage message)
31 m_messageQueue.Enqueue(message);
34 bool ProcessAllAvailableMessages()
38 OnBeforeMessagesHandled();
40 while(m_messageQueue.TryDequeue(message))
42 bool continueRunning = ProcessMessage(message);
51 bool WaitAndProcessSingleMessage()
53 TMessage message = m_messageQueue.Dequeue();
54 bool continueRunning = ProcessMessage(message);
55 return continueRunning;
58 virtual void OnMessageHandled(TMessage message) { }
59 virtual void OnBeforeMessagesHandled() { }
60 virtual void OnAllMessagesHandled() { }
61 virtual void OnStarted() { }
62 virtual void OnStopped() { }
67 bool ProcessMessage(TMessage message)
69 bool continueRunning = message->Handle(*
this);
70 OnMessageHandled(message);
71 return continueRunning;