7#include <aws/core/client/ClientConfiguration.h>
8#include <aws/queues/Queues_EXPORTS.h>
17 static const char*
MEM_TAG =
"Aws::Queues::Queue";
23 template<
typename MESSAGE_TYPE>
26 typedef std::function<void(
const Queue*,
const MESSAGE_TYPE&,
bool&)> MessageReceivedEventHandler;
27 typedef std::function<void(
const Queue*,
const MESSAGE_TYPE&)> MessageDeleteFailedEventHandler;
28 typedef std::function<void(
const Queue*,
const MESSAGE_TYPE&)> MessageDeleteSuccessEventHandler;
29 typedef std::function<void(
const Queue*,
const MESSAGE_TYPE&)> MessageSendFailedEventHandler;
30 typedef std::function<void(
const Queue*,
const MESSAGE_TYPE&)> MessageSendSuccessEventHandler;
39 Queue(
unsigned pollingFrequency) :
40 m_continue(true), m_pollingFrequencyMs(pollingFrequency), m_pollingThread(nullptr)
49 virtual MESSAGE_TYPE
Top()
const = 0;
50 virtual void Delete(
const MESSAGE_TYPE&) = 0;
51 virtual void Push(
const MESSAGE_TYPE&) = 0;
78 m_pollingThread->join();
79 m_pollingThread =
nullptr;
109 auto start = std::chrono::system_clock::now();
126 auto stop = std::chrono::system_clock::now();
129 if (m_pollingFrequencyMs >=
timeTaken.count())
131 std::this_thread::sleep_for(std::chrono::milliseconds(m_pollingFrequencyMs -
timeTaken.count()));
137 unsigned m_pollingFrequencyMs;
141 MessageReceivedEventHandler m_messageReceivedHandler;
142 MessageDeleteFailedEventHandler m_messageDeleteFailedHandler;
143 MessageDeleteSuccessEventHandler m_messageDeleteSuccessHandler;
144 MessageSendFailedEventHandler m_messageSendFailedHandler;
145 MessageSendSuccessEventHandler m_messageSendSuccessHandler;
const MessageDeleteFailedEventHandler & GetMessageDeleteFailedEventHandler() const
void SetMessageDeleteSuccessEventHandler(const MessageDeleteSuccessEventHandler &messageHandler)
const MessageSendFailedEventHandler & GetMessageSendFailedEventHandler() const
const MessageDeleteSuccessEventHandler & GetMessageDeleteSuccessEventHandler() const
virtual MESSAGE_TYPE Top() const =0
void SetMessageSendFailedEventHandler(const MessageSendFailedEventHandler &messageHandler)
const MessageSendSuccessEventHandler & GetMessageSendSuccessEventHandler() const
virtual void Delete(const MESSAGE_TYPE &)=0
void SetMessageSendSuccessEventHandler(const MessageSendSuccessEventHandler &messageHandler)
Queue(unsigned pollingFrequency)
void SetMessageReceivedEventHandler(MessageReceivedEventHandler &&messageHandler)
void SetMessageDeleteFailedEventHandler(const MessageDeleteFailedEventHandler &messageHandler)
void SetMessageDeleteSuccessEventHandler(MessageDeleteSuccessEventHandler &&messageHandler)
virtual void Push(const MESSAGE_TYPE &)=0
void SetMessageReceivedEventHandler(const MessageReceivedEventHandler &messageHandler)
void SetMessageSendSuccessEventHandler(MessageSendSuccessEventHandler &&messageHandler)
std::atomic< bool > m_continue
void SetMessageDeleteFailedEventHandler(MessageDeleteFailedEventHandler &&messageHandler)
const MessageReceivedEventHandler & GetMessageReceivedEventHandler() const
void SetMessageSendFailedEventHandler(MessageSendFailedEventHandler &&messageHandler)
static const char * MEM_TAG
UniquePtr< T > MakeUnique(const char *allocationTag, ArgTypes &&... args)
std::unique_ptr< T, D > UniquePtr