F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DelegateMutex.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/DelegateMutex.hpp
3 // \brief Define the Os::DelegateMutex class
4 // ======================================================================
5 #ifndef OS_DELEGATEMUTEX_HPP_
6 #define OS_DELEGATEMUTEX_HPP_
7 
8 #include "Os/MutexInterface.hpp"
9 
10 namespace Os {
11 
19 class DelegateMutex final : public MutexInterface {
20  public:
21  DelegateMutex();
22  ~DelegateMutex() final;
23 
25  DelegateMutex(const DelegateMutex& other) = delete;
26 
28  DelegateMutex& operator=(const DelegateMutex& other) = delete;
29 
32  MutexHandle* getHandle() override;
33 
34  Status take() override;
35  Status release() override;
36 
37  private:
38  // This section is used to store the implementation-defined mutex handle. To Os::Mutex and fprime, this type is
39  // opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store the handle in
40  // the byte-array here and set `m_delegate` to that address for storage.
41  //
42  alignas(FW_HANDLE_ALIGNMENT) MutexHandleStorage m_handle_storage;
43  MutexInterface& m_delegate;
44 };
45 
46 } // namespace Os
47 
48 #endif // OS_DELEGATEMUTEX_HPP_
DelegateMutex()
Constructor. Mutex is unlocked when created.
Link-time delegating Mutex implementation.
~DelegateMutex() final
Destructor.
DelegateMutex & operator=(const DelegateMutex &other)=delete
assignment operator is forbidden
Status release() override
unlock the mutex and get return status
MutexHandle * getHandle() override
return the underlying mutex handle (implementation specific)
Status take() override
lock the mutex and get return status
U8 MutexHandleStorage[FW_MUTEX_HANDLE_MAX_SIZE]
Definition: Os.hpp:12