F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
CountingSemaphore.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Darwin/CountingSemaphore.hpp
3 // \brief Darwin definitions for Os::CountingSemaphore
4 // ======================================================================
5 #ifndef OS_DARWIN_COUNTING_SEMAPHORE_HPP
6 #define OS_DARWIN_COUNTING_SEMAPHORE_HPP
7 #include <dispatch/dispatch.h>
9 
10 namespace Os {
11 namespace Darwin {
12 namespace Semaphore {
13 
15  dispatch_semaphore_t m_semaphore = nullptr;
16  long m_initial_count = 0;
17 };
18 
20  public:
21  explicit DarwinCountingSemaphore(U32 initial_count);
22 
23  ~DarwinCountingSemaphore() override;
24 
25  DarwinCountingSemaphore(const DarwinCountingSemaphore& other) = delete;
26 
28 
29  Status wait() override;
30 
31  Status waitTimeout(const Fw::TimeInterval& interval) override;
32 
33  Status tryWait() override;
34 
35  Status post() override;
36 
38 
39  private:
41 };
42 
43 } // namespace Semaphore
44 } // namespace Darwin
45 } // namespace Os
46 #endif // OS_DARWIN_COUNTING_SEMAPHORE_HPP
Status tryWait() override
non-blocking attempt to decrement the semaphore
Status waitTimeout(const Fw::TimeInterval &interval) override
wait on the semaphore with a timeout
CountingSemaphoreHandle * getHandle() override
return the underlying semaphore handle (implementation specific)
Status post() override
post (increment) the semaphore, potentially waking a waiting thread
CountingSemaphoreInterface & operator=(const CountingSemaphoreInterface &other)=delete
Status wait() override
wait (decrement) the semaphore, blocking if count is zero