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