GCC Code Coverage Report


Directory: ./
File: Os/Posix/ConditionVariable.cpp
Date: 2026-09-23 21:11:01
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 3475 PosixConditionVariable::PosixConditionVariable() {
15
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 3475 times.
3475 int status = pthread_cond_init(&this->m_handle.m_condition, nullptr);
16 3475 FW_ASSERT(status == 0, static_cast<FwAssertArgType>(status)); // If this fails, something horrible happened.
17 3475 }
18 6950 PosixConditionVariable::~PosixConditionVariable() {
19
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 3475 times.
6950 (void)pthread_cond_destroy(&this->m_handle.m_condition);
20 6950 }
21
22 14 PosixConditionVariable::Status PosixConditionVariable::pend(Os::Mutex& mutex) {
23 14 PosixMutexHandle* mutex_handle = reinterpret_cast<PosixMutexHandle*>(mutex.getHandle());
24 14 FW_ASSERT(mutex_handle != nullptr);
25
2/4
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
14 int status = pthread_cond_wait(&this->m_handle.m_condition, &mutex_handle->m_mutex_descriptor);
26 14 return posix_status_to_conditional_status(status);
27 }
28 315282 void PosixConditionVariable::notify() {
29
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 315282 times.
315282 const int status = pthread_cond_signal(&this->m_handle.m_condition);
30 315282 FW_ASSERT(status == 0);
31 315282 }
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