GCC Code Coverage Report


Directory: ./
File: Os/Mutex.cpp
Date: 2026-09-23 21:11:01
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 9 9 100.0%
Branches: 3 3 100.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Mutex.cpp
3 // \brief common function implementation for Os::Mutex
4 // ======================================================================
5 #include <Fw/Types/Assert.hpp>
6 #include <Os/Mutex.hpp>
7
8 namespace Os {
9
10
3/3
✓ Branch 10 taken 706824 times.
✓ Branch 11 taken 9817 times.
✓ Branch 17 taken 9817 times.
716641 Mutex::Mutex() : m_handle_storage(), m_delegate(*MutexInterface::getDelegate(m_handle_storage)) {
11 9817 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
12 9817 }
13
14 19636 Mutex::~Mutex() {
15 19634 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
16 19634 m_delegate.~MutexInterface();
17 19636 }
18
19 15 MutexHandle* Mutex::getHandle() {
20 15 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
21 15 return this->m_delegate.getHandle();
22 }
23
24 5301860 Mutex::Status Mutex::take() {
25 5301860 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
26 6272635 return this->m_delegate.take();
27 }
28
29 5393891 Mutex::Status Mutex::release() {
30 5393891 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
31 6321058 return this->m_delegate.release();
32 }
33
34 5400329 void Mutex::lock() {
35 5400329 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
36 6287577 Mutex::Status status = this->take();
37 5611255 FW_ASSERT(status == Mutex::Status::OP_OK,
38 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(this)), status);
39 5611255 }
40
41 5377082 void Mutex::unLock() {
42 5377082 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
43 6367211 Mutex::Status status = this->release();
44 6077033 FW_ASSERT(status == Mutex::Status::OP_OK,
45 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(this)), status);
46 6077033 }
47
48 706554 ScopeLock::ScopeLock(Mutex& mutex) : m_mutex(mutex) {
49 706554 this->m_mutex.lock();
50 706556 }
51
52 706549 ScopeLock::~ScopeLock() {
53 706549 this->m_mutex.unLock();
54 706553 }
55
56 } // namespace Os
57