GCC Code Coverage Report


Directory: ./
File: Os/Posix/ConditionVariable.cpp
Date: 2026-10-14 21:15:02
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 3655 PosixConditionVariable::PosixConditionVariable() {
15
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 3655 times.
3655 int status = pthread_cond_init(&this->m_handle.m_condition, nullptr);
16 3655 FW_ASSERT(status == 0, static_cast<FwAssertArgType>(status)); // If this fails, something horrible happened.
17 3655 }
18 7310 PosixConditionVariable::~PosixConditionVariable() {
19
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 3655 times.
7310 (void)pthread_cond_destroy(&this->m_handle.m_condition);
20 7310 }
21
22 11 PosixConditionVariable::Status PosixConditionVariable::pend(Os::Mutex& mutex) {
23 // Os::Mutex is selected as a pair with this implementation (config/OsSelection.hpp), so its handle is a
24 // PosixMutexHandle
25 11 PosixMutexHandle* mutex_handle = reinterpret_cast<PosixMutexHandle*>(mutex.getHandle());
26 11 FW_ASSERT(mutex_handle != nullptr);
27
2/4
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
11 int status = pthread_cond_wait(&this->m_handle.m_condition, &mutex_handle->m_mutex_descriptor);
28 11 return posix_status_to_conditional_status(status);
29 }
30 379341 void PosixConditionVariable::notify() {
31
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 379341 times.
379341 const int status = pthread_cond_signal(&this->m_handle.m_condition);
32 379341 FW_ASSERT(status == 0);
33 379341 }
34 1 void PosixConditionVariable::notifyAll() {
35
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 const int status = pthread_cond_broadcast(&this->m_handle.m_condition);
36 1 FW_ASSERT(status == 0);
37 1 }
38
39 ✗ ConditionVariableHandle* PosixConditionVariable::getHandle() {
40 ✗ return &m_handle;
41 }
42
43 } // namespace Mutex
44 } // namespace Posix
45 } // namespace Os
46