repairing host osal

This commit is contained in:
Robin Müller 2020-09-05 20:39:10 +02:00
parent 05814dc805
commit 39b675cf99
7 changed files with 20 additions and 17 deletions

View File

@ -122,8 +122,11 @@ void FixedTimeslotTask::taskFunctionality() {
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
uint32_t slotTimeMs, int8_t executionStep) { uint32_t slotTimeMs, int8_t executionStep) {
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) { ExecutableObjectIF* executableObject = objectManager->
pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, this); get<ExecutableObjectIF>(componentId);
if (executableObject!= nullptr) {
pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep,
executableObject, this);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -61,7 +61,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
} }
// not sure this will work.. // not sure this will work..
//*message = std::move(messageQueue.front()); //*message = std::move(messageQueue.front());
MutexHelper mutexLock(queueLock, 20); MutexHelper mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
MessageQueueMessage* currentMessage = &messageQueue.front(); MessageQueueMessage* currentMessage = &messageQueue.front();
std::copy(currentMessage->getBuffer(), std::copy(currentMessage->getBuffer(),
currentMessage->getBuffer() + messageSize, message->getBuffer()); currentMessage->getBuffer() + messageSize, message->getBuffer());
@ -126,7 +126,8 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
} }
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) { if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
MutexHelper mutexLock(targetQueue->queueLock, 20); MutexHelper mutexLock(targetQueue->queueLock,
MutexIF::TimeoutType::WAITING, 20);
// not ideal, works for now though. // not ideal, works for now though.
MessageQueueMessage* mqmMessage = MessageQueueMessage* mqmMessage =
dynamic_cast<MessageQueueMessage*>(message); dynamic_cast<MessageQueueMessage*>(message);
@ -146,8 +147,9 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t MessageQueue::lockQueue(dur_millis_t lockTimeout) { ReturnValue_t MessageQueue::lockQueue(MutexIF::TimeoutType timeoutType,
return queueLock->lockMutex(lockTimeout); dur_millis_t lockTimeout) {
return queueLock->lockMutex(timeoutType, lockTimeout);
} }
ReturnValue_t MessageQueue::unlockQueue() { ReturnValue_t MessageQueue::unlockQueue() {

View File

@ -182,7 +182,8 @@ public:
bool isDefaultDestinationSet() const override; bool isDefaultDestinationSet() const override;
ReturnValue_t lockQueue(dur_millis_t lockTimeout); ReturnValue_t lockQueue(MutexIF::TimeoutType timeoutType,
dur_millis_t lockTimeout);
ReturnValue_t unlockQueue(); ReturnValue_t unlockQueue();
protected: protected:
/** /**

View File

@ -1,10 +1,9 @@
#include "../../osal/host/Mutex.h" #include "Mutex.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
const uint32_t MutexIF::POLLING = 0; Mutex::Mutex() {}
const uint32_t MutexIF::BLOCKING = 0xffffffff;
ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) { ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
if(timeoutMs == MutexIF::BLOCKING) { if(timeoutMs == MutexIF::BLOCKING) {
mutex.lock(); mutex.lock();
locked = true; locked = true;

View File

@ -15,8 +15,9 @@
*/ */
class Mutex : public MutexIF { class Mutex : public MutexIF {
public: public:
Mutex() = default; Mutex();
ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING) override; ReturnValue_t lockMutex(TimeoutType timeoutType =
TimeoutType::BLOCKING, uint32_t timeoutMs = 0) override;
ReturnValue_t unlockMutex() override; ReturnValue_t unlockMutex() override;
std::timed_mutex* getMutexHandle(); std::timed_mutex* getMutexHandle();

View File

@ -37,7 +37,7 @@ ReturnValue_t QueueMapManager::addMessageQueue(
MessageQueueIF* QueueMapManager::getMessageQueue( MessageQueueIF* QueueMapManager::getMessageQueue(
MessageQueueId_t messageQueueId) const { MessageQueueId_t messageQueueId) const {
MutexHelper(mapLock, 50); MutexHelper(MutexIF::TimeoutType::WAITING, mapLock, 50);
auto queueIter = queueMap.find(messageQueueId); auto queueIter = queueMap.find(messageQueueId);
if(queueIter != queueMap.end()) { if(queueIter != queueMap.end()) {
return queueIter->second; return queueIter->second;

View File

@ -3,9 +3,6 @@
#include "../../osal/linux/CountingSemaphore.h" #include "../../osal/linux/CountingSemaphore.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
const uint32_t SemaphoreIF::POLLING = 0;
const uint32_t SemaphoreIF::BLOCKING = 0xFFFFFFFF;
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
SemaphoreFactory::SemaphoreFactory() { SemaphoreFactory::SemaphoreFactory() {