43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
/**
|
|
* @file QueuedMessage.h
|
|
* @brief <brief>
|
|
* @date Aug 4, 2015
|
|
* @author rheijden
|
|
* @copyright 2015 Dual Inventive Technology Centre B.V.
|
|
*
|
|
* <description>
|
|
*/
|
|
#ifndef INCLUDE_QUEUEDMESSAGE_H_
|
|
#define INCLUDE_QUEUEDMESSAGE_H_
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <chrono>
|
|
#include <atomic>
|
|
#include <di/Mailbox.h>
|
|
#include <di/Timer.h>
|
|
|
|
struct Message;
|
|
|
|
class QueuedMessage {
|
|
public:
|
|
static uint16_t sReplyTimeoutSec;
|
|
|
|
QueuedMessage(uint32_t id_, const std::shared_ptr<struct Message> &msg) :
|
|
id(id_),
|
|
message(msg),
|
|
isReplied(false) {
|
|
timeout.set(std::chrono::seconds(sReplyTimeoutSec));
|
|
timeout.start();
|
|
}
|
|
|
|
std::mutex lock; //<! mutex to lock the message
|
|
uint32_t id; //<! id of the message
|
|
std::shared_ptr<struct Message> message; //<! pointer to the message
|
|
Di::Timer timeout; //<! value till timeout
|
|
bool isReplied; //<! boolean to see if there has been a reply
|
|
std::shared_ptr<Di::Mailbox<std::string>> replyMailbox; //<! pointer to reply mailbox
|
|
};
|
|
|
|
#endif // INCLUDE_QUEUEDMESSAGE_H_
|