F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DelegateMutex.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/DelegateMutex.cpp
3 // \brief implementation of Os::DelegateMutex (link-time delegating Os::Mutex)
4 // ======================================================================
5 #include <Fw/Types/Assert.hpp>
6 #include <Os/DelegateMutex.hpp>
7 
8 namespace Os {
9 
10 // ----------------------------------------------------------------------
11 // DelegateMutex: link-time delegating implementation
12 // ----------------------------------------------------------------------
13 
14 DelegateMutex::DelegateMutex() : m_delegate(*MutexInterface::getDelegate(m_handle_storage)) {
15  // m_handle_storage is placement-new storage populated by getDelegate(); do not value-initialize it (#5297)
16  FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
17 }
18 
20  FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
21  m_delegate.~MutexInterface();
22 }
23 
25  FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
26  return this->m_delegate.getHandle();
27 }
28 
30  FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
31  return this->m_delegate.take();
32 }
33 
35  FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
36  return this->m_delegate.release();
37 }
38 
39 } // namespace Os
DelegateMutex()
Constructor. Mutex is unlocked when created.
virtual Status release()=0
unlock the mutex return status
~DelegateMutex() final
Destructor.
virtual Status take()=0
lock the mutex return status
virtual MutexHandle * getHandle()=0
return the underlying mutex handle (implementation specific)
Status release() override
unlock the mutex and get return status
virtual ~MutexInterface()=default
default virtual destructor
MutexHandle * getHandle() override
return the underlying mutex handle (implementation specific)
Status take() override
lock the mutex and get return status
#define FW_ASSERT(...)
Definition: Assert.hpp:14