30 lines
978 B
C++
30 lines
978 B
C++
#include "MutexExample.h"
|
|
|
|
#include <fsfw/ipc/MutexFactory.h>
|
|
#include <fsfw/serviceinterface.h>
|
|
|
|
void MutexExample::example() {
|
|
MutexIF* mutex = MutexFactory::instance()->createMutex();
|
|
MutexIF* mutex2 = MutexFactory::instance()->createMutex();
|
|
|
|
ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
FSFW_FLOGET("MutexExample::example: Lock Failed with {}\n", result);
|
|
}
|
|
|
|
result = mutex2->lockMutex(MutexIF::TimeoutType::BLOCKING);
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
FSFW_FLOGET("MutexExample::example: Lock Failed with {}\n", result);
|
|
}
|
|
|
|
result = mutex->unlockMutex();
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
FSFW_FLOGET("MutexExample::example: Unlock Failed with {}\n", result);
|
|
}
|
|
|
|
result = mutex2->unlockMutex();
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
FSFW_FLOGET("MutexExample::example: Unlock Failed with {}\n", result);
|
|
}
|
|
}
|