F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Mutex.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Stub/Mutex.hpp
3 // \brief stub definitions for Os::Mutex
4 // ======================================================================
5 #include "Os/Mutex.hpp"
6 
7 #include <atomic>
8 
9 #ifndef OS_STUB_MUTEX_HPP
10 #define OS_STUB_MUTEX_HPP
11 namespace Os {
12 namespace Stub {
13 namespace Mutex {
14 
15 struct StubMutexHandle : public MutexHandle {
17  std::atomic<bool> m_mutex_taken = {false};
18 };
19 
29 class StubMutex : public MutexInterface {
30  public:
33  StubMutex() = default;
34 
37  ~StubMutex() override = default;
38 
41  MutexHandle* getHandle() override;
42 
43  Status take() override;
44  Status release() override;
45 
46  private:
48  StubMutexHandle m_handle;
49 };
50 
51 } // namespace Mutex
52 } // namespace Stub
53 } // namespace Os
54 #endif // OS_STUB_MUTEX_HPP
Nonblocking stub implementation of Os::Mutex.
Definition: Mutex.hpp:29
MutexHandle * getHandle() override
return the underlying mutex handle (implementation specific)
Definition: Mutex.cpp:34
Status release() override
unlock the mutex and get return status
Definition: Mutex.cpp:23
Status take() override
lock the mutex and get return status
Definition: Mutex.cpp:11
StubMutex()=default
constructor
~StubMutex() override=default
destructor
std::atomic< bool > m_mutex_taken
True if the mutex has been acquired without being released.
Definition: Mutex.hpp:17