F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DelegateConditionVariable.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/DelegateConditionVariable.cpp
3 // \brief implementation of Os::DelegateConditionVariable (link-time delegating Os::ConditionVariable)
4 // ======================================================================
6 #include "Fw/Types/Assert.hpp"
7 
8 namespace Os {
10  : m_delegate(*ConditionVariableInterface::getDelegate(m_handle_storage)) {}
11 
13  m_delegate.~ConditionVariableInterface();
14 }
15 
17  FW_ASSERT(&this->m_delegate == reinterpret_cast<ConditionVariableInterface*>(&this->m_handle_storage[0]));
18  if (this->m_lock != nullptr && this->m_lock != &mutex) {
19  return Status::ERROR_DIFFERENT_MUTEX;
20  }
21  this->m_lock = &mutex;
22  return this->m_delegate.pend(mutex);
23 }
25  FW_ASSERT(&this->m_delegate == reinterpret_cast<ConditionVariableInterface*>(&this->m_handle_storage[0]));
26  this->m_delegate.notify();
27 }
29  FW_ASSERT(&this->m_delegate == reinterpret_cast<ConditionVariableInterface*>(&this->m_handle_storage[0]));
30  this->m_delegate.notifyAll();
31 }
32 
34  FW_ASSERT(&this->m_delegate == reinterpret_cast<const ConditionVariableInterface*>(&this->m_handle_storage[0]));
35  return this->m_delegate.getHandle();
36 }
37 
38 } // namespace Os
void notify() override
notify a single waiter on this condition variable
~DelegateConditionVariable() final
default virtual destructor
virtual Status pend(Os::Mutex &mutex)=0
wait on a condition variable
DelegateConditionVariable()
default constructor
Link-time delegating Mutex implementation.
virtual void notifyAll()=0
notify all waiters on this condition variable
virtual ~ConditionVariableInterface()=default
Default destructor.
virtual ConditionVariableHandle * getHandle()=0
return the underlying condition variable handle (implementation specific).
Status pend(Os::Mutex &mutex) override
wait on a condition variable
interface for condition variables
ConditionVariableHandle * getHandle() override
return the underlying condition variable handle (implementation specific). Delegates to implementatio...
virtual void notify()=0
notify a single waiter on this condition variable
void notifyAll() override
notify all waiters on this condition variable
Condition variable handle parent.
#define FW_ASSERT(...)
Definition: Assert.hpp:14