deleted copy ans assignment ctor

This commit is contained in:
Robin Müller 2020-05-18 17:38:19 +02:00
parent d1500a7868
commit f8614e23a8
2 changed files with 20 additions and 14 deletions

View File

@ -7,11 +7,10 @@
// As a first step towards this, introduces system context variable which needs // As a first step towards this, introduces system context variable which needs
// to be switched manually // to be switched manually
// Haven't found function to find system context. // Haven't found function to find system context.
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize) : MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize) {
defaultDestination(0),lastPartner(0), callContext(CallContext::task) {
handle = xQueueCreate(messageDepth, maxMessageSize); handle = xQueueCreate(messageDepth, maxMessageSize);
if (handle == NULL) { if (handle == NULL) {
sif::error << "MessageQueue creation failed" << std::endl; sif::error << "MessageQueue: Creation failed" << std::endl;
} }
} }
@ -57,11 +56,11 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) { ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) {
if (result != pdPASS) { if (result != pdPASS) {
if (!ignoreFault) { if (not ignoreFault) {
InternalErrorReporterIF* internalErrorReporter = InternalErrorReporterIF* internalErrorReporter =
objectManager->get<InternalErrorReporterIF>( objectManager->get<InternalErrorReporterIF>(
objects::INTERNAL_ERROR_REPORTER); objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter != NULL) { if (internalErrorReporter != nullptr) {
internalErrorReporter->queueMessageNotSent(); internalErrorReporter->queueMessageNotSent();
} }
} }
@ -106,6 +105,7 @@ MessageQueueId_t MessageQueue::getId() const {
} }
void MessageQueue::setDefaultDestination(MessageQueueId_t defaultDestination) { void MessageQueue::setDefaultDestination(MessageQueueId_t defaultDestination) {
defaultDestinationSet = true;
this->defaultDestination = defaultDestination; this->defaultDestination = defaultDestination;
} }
@ -114,7 +114,7 @@ MessageQueueId_t MessageQueue::getDefaultDestination() const {
} }
bool MessageQueue::isDefaultDestinationSet() const { bool MessageQueue::isDefaultDestinationSet() const {
return 0; return defaultDestinationSet;
} }
@ -129,9 +129,9 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
static_cast<const void*>(message->getBuffer()), 0); static_cast<const void*>(message->getBuffer()), 0);
} }
else { else {
// If the call context is from an interrupt, /* If the call context is from an interrupt,
// request a context switch if a higher priority task * request a context switch if a higher priority task
// was blocked by the interrupt. * was blocked by the interrupt. */
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
result = xQueueSendFromISR(reinterpret_cast<QueueHandle_t>(sendTo), result = xQueueSendFromISR(reinterpret_cast<QueueHandle_t>(sendTo),
static_cast<const void*>(message->getBuffer()), static_cast<const void*>(message->getBuffer()),

View File

@ -56,8 +56,12 @@ public:
* With this parameter, the maximum message size can be adjusted. * With this parameter, the maximum message size can be adjusted.
* This should be left default. * This should be left default.
*/ */
MessageQueue( size_t message_depth = 3, MessageQueue( size_t messageDepth = 3,
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE ); size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE );
/** Copying message queues forbidden */
MessageQueue(const MessageQueue&) = delete;
MessageQueue& operator=(const MessageQueue&) = delete;
/** /**
* @brief The destructor deletes the formerly created message queue. * @brief The destructor deletes the formerly created message queue.
@ -189,10 +193,12 @@ protected:
static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault); static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
private: private:
bool defaultDestinationSet = false;
QueueHandle_t handle; QueueHandle_t handle;
MessageQueueId_t defaultDestination; MessageQueueId_t defaultDestination = 0;
MessageQueueId_t lastPartner; MessageQueueId_t lastPartner = 0;
CallContext callContext; //!< Stores the current system context //!< Stores the current system context
CallContext callContext = CallContext::task;
}; };
#endif /* MESSAGEQUEUE_H_ */ #endif /* MESSAGEQUEUE_H_ */