moved mutex.cpp

This commit is contained in:
Robin Müller 2021-07-16 16:11:58 +02:00
parent eb89615722
commit a6e5b267a3
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 33 additions and 33 deletions

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_OSAL_HOST_MESSAGEQUEUE_H_
#define FRAMEWORK_OSAL_HOST_MESSAGEQUEUE_H_
#include "../../internalError/InternalErrorReporterIF.h"
#include "fsfw/internalerror/InternalErrorReporterIF.h"
#include "../../ipc/MessageQueueIF.h"
#include "../../ipc/MessageQueueMessage.h"
#include "../../ipc/MutexIF.h"

View File

@ -1,32 +0,0 @@
#include "Mutex.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
Mutex::Mutex() {}
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
if(timeoutType == TimeoutType::BLOCKING) {
mutex.lock();
return HasReturnvaluesIF::RETURN_OK;
}
else if(timeoutType == TimeoutType::POLLING) {
if(mutex.try_lock()) {
return HasReturnvaluesIF::RETURN_OK;
}
}
else if(timeoutType == TimeoutType::WAITING){
auto chronoMs = std::chrono::milliseconds(timeoutMs);
if(mutex.try_lock_for(chronoMs)) {
return HasReturnvaluesIF::RETURN_OK;
}
}
return MutexIF::MUTEX_TIMEOUT;
}
ReturnValue_t Mutex::unlockMutex() {
mutex.unlock();
return HasReturnvaluesIF::RETURN_OK;
}
std::timed_mutex* Mutex::getMutexHandle() {
return &mutex;
}

32
src/osal/host/Mutex.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "fsfw/osal/host/Mutex.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#
Mutex::Mutex() {}
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
if(timeoutType == TimeoutType::BLOCKING) {
mutex.lock();
return HasReturnvaluesIF::RETURN_OK;
}
else if(timeoutType == TimeoutType::POLLING) {
if(mutex.try_lock()) {
return HasReturnvaluesIF::RETURN_OK;
}
}
else if(timeoutType == TimeoutType::WAITING){
auto chronoMs = std::chrono::milliseconds(timeoutMs);
if(mutex.try_lock_for(chronoMs)) {
return HasReturnvaluesIF::RETURN_OK;
}
}
return MutexIF::MUTEX_TIMEOUT;
}
ReturnValue_t Mutex::unlockMutex() {
mutex.unlock();
return HasReturnvaluesIF::RETURN_OK;
}
std::timed_mutex* Mutex::getMutexHandle() {
return &mutex;
}