GCC Code Coverage Report


Directory: Os/Posix/
File: ConditionVariable.cpp
Date: 2026-09-03 21:16:08
Exec Total Coverage
Lines: 20 22 90.9%
Functions: 5 6 83.3%
Branches: 6 12 50.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Posix/ConditionVariable.cpp
3 // \brief Posix implementations for Os::ConditionVariable
4 // ======================================================================
5 #include "Os/Posix/ConditionVariable.hpp"
6 #include "Fw/Types/Assert.hpp"
7 #include "Os/Posix/Mutex.hpp"
8 #include "Os/Posix/error.hpp"
9
10 namespace Os {
11 namespace Posix {
12 namespace Mutex {
13
14 25 PosixConditionVariable::PosixConditionVariable() {
15
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 int status = pthread_cond_init(&this->m_handle.m_condition, nullptr);
16 25 FW_ASSERT(status == 0, static_cast<FwAssertArgType>(status)); // If this fails, something horrible happened.
17 25 }
18 50 PosixConditionVariable::~PosixConditionVariable() {
19
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
50 (void)pthread_cond_destroy(&this->m_handle.m_condition);
20 50 }
21
22 10 PosixConditionVariable::Status PosixConditionVariable::pend(Os::Mutex& mutex) {
23 10 PosixMutexHandle* mutex_handle = reinterpret_cast<PosixMutexHandle*>(mutex.getHandle());
24 10 FW_ASSERT(mutex_handle != nullptr);
25
2/4
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
10 int status = pthread_cond_wait(&this->m_handle.m_condition, &mutex_handle->m_mutex_descriptor);
26 10 return posix_status_to_conditional_status(status);
27 }
28 11 void PosixConditionVariable::notify() {
29
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 const int status = pthread_cond_signal(&this->m_handle.m_condition);
30 11 FW_ASSERT(status == 0);
31 11 }
32 1 void PosixConditionVariable::notifyAll() {
33
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 const int status = pthread_cond_broadcast(&this->m_handle.m_condition);
34 1 FW_ASSERT(status == 0);
35 1 }
36
37 ConditionVariableHandle* PosixConditionVariable::getHandle() {
38 return &m_handle;
39 }
40
41 } // namespace Mutex
42 } // namespace Posix
43 } // namespace Os
44