F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
Condition.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title Os/Condition.hpp
3// \brief common function definitions for Os::ConditionVariables
4// ======================================================================
5#include "Os/Mutex.hpp"
6#include "Os/Os.hpp"
7
8#ifndef OS_CONDITION_HPP_
9#define OS_CONDITION_HPP_
10
11namespace Os {
12
15
21 public:
25 virtual ~ConditionVariableInterface() = default;
26
29
32
40 virtual void wait(Os::Mutex& mutex) = 0;
41
46 virtual void notify() = 0;
47
52 virtual void notifyAll() = 0;
53
57
60};
61
67 public:
70
72 ~ConditionVariable() final;
73
76
79
82
94 void wait(Os::Mutex& mutex) override;
95
101 void notify() override;
102
108 void notifyAll() override;
109
113
114 private:
116 Os::Mutex* m_lock = nullptr;
117
118 // This section is used to store the implementation-defined file handle. To Os::File and fprime, this type is
119 // opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store then handle in
120 // the byte-array here and set `handle` to that address for storage.
121 alignas(FW_HANDLE_ALIGNMENT) ConditionVariableHandleStorage m_handle_storage;
122 ConditionVariableInterface& m_delegate;
123};
124}
125#endif //OS_CONDITION_HPP_
#define FW_HANDLE_ALIGNMENT
Alignment of handle storage.
Definition FpConfig.h:440
U8 ConditionVariableHandleStorage[FW_CONDITION_VARIABLE_HANDLE_MAX_SIZE]
Definition Os.hpp:17
Condition variable handle parent.
Definition Condition.hpp:14
condition variable implementation
Definition Condition.hpp:66
void notifyAll() override
notify all waiters on this condition variable
Definition Condition.cpp:24
ConditionVariableHandle * getHandle() override
return the underlying condition variable handle (implementation specific). Delegates to implementatio...
Definition Condition.cpp:29
ConditionVariable()
default constructor
Definition Condition.cpp:5
~ConditionVariable() final
default virtual destructor
Definition Condition.cpp:7
ConditionVariable(const ConditionVariableInterface *other)=delete
copy constructor is forbidden
void notify() override
notify a single waiter on this condition variable
Definition Condition.cpp:20
ConditionVariableInterface & operator=(const ConditionVariableInterface &other) override=delete
assignment operator is forbidden
ConditionVariable(const ConditionVariableInterface &other)=delete
copy constructor is forbidden
void wait(Os::Mutex &mutex) override
wait on a condition variable
Definition Condition.cpp:11
interface for condition variables
Definition Condition.hpp:20
static ConditionVariableInterface * getDelegate(ConditionVariableHandleStorage &aligned_new_memory)
provide a pointer to a Mutex delegate object
virtual void notifyAll()=0
notify all waiters on this condition variable
virtual ~ConditionVariableInterface()=default
Default destructor.
ConditionVariableInterface(const ConditionVariableInterface &other)=delete
copy constructor is forbidden
virtual ConditionVariableHandle * getHandle()=0
return the underlying condition variable handle (implementation specific).
virtual ConditionVariableInterface & operator=(const ConditionVariableInterface &other)=delete
assignment operator is forbidden
ConditionVariableInterface()=default
Default constructor.
virtual void notify()=0
notify a single waiter on this condition variable
virtual void wait(Os::Mutex &mutex)=0
wait on a condition variable