2020-06-05 17:55:03 +02:00
|
|
|
#include <framework/ipc/QueueFactory.h>
|
|
|
|
#include <framework/osal/host/MessageQueue.h>
|
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
QueueFactory* QueueFactory::factoryInstance = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo,
|
2020-06-11 02:03:18 +02:00
|
|
|
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
2020-06-05 17:55:03 +02:00
|
|
|
bool ignoreFault) {
|
|
|
|
return MessageQueue::sendMessageFromMessageQueue(sendTo,message,
|
|
|
|
sentFrom,ignoreFault);
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueueFactory* QueueFactory::instance() {
|
|
|
|
if (factoryInstance == nullptr) {
|
|
|
|
factoryInstance = new QueueFactory;
|
|
|
|
}
|
|
|
|
return factoryInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueueFactory::QueueFactory() {
|
|
|
|
}
|
|
|
|
|
|
|
|
QueueFactory::~QueueFactory() {
|
|
|
|
}
|
|
|
|
|
2020-06-05 21:36:50 +02:00
|
|
|
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth,
|
2020-06-05 17:55:03 +02:00
|
|
|
size_t maxMessageSize) {
|
|
|
|
// A thread-safe queue can be implemented by using a combination
|
|
|
|
// of std::queue and std::mutex. This uses dynamic memory allocation
|
|
|
|
// which could be alleviated by using a custom allocator, external library
|
|
|
|
// (etl::queue) or simply using std::queue, we're on a host machine anyway.
|
|
|
|
return new MessageQueue(messageDepth, maxMessageSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) {
|
|
|
|
delete queue;
|
|
|
|
}
|