GCC Code Coverage Report


Directory: ./
File: Os/Mutex.cpp
Date: 2026-09-23 22:11:34
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 1 taken 5832 times.
✓ Branch 2 taken 81 times.
✓ Branch 4 taken 81 times.
5913 Mutex::Mutex() : m_handle_storage(), m_delegate(*MutexInterface::getDelegate(m_handle_storage)) {
11 81 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
12 81 }
13
14 162 Mutex::~Mutex() {
15 162 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
16 162 m_delegate.~MutexInterface();
17 162 }
18
19 5106 MutexHandle* Mutex::getHandle() {
20 5106 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
21 5106 return this->m_delegate.getHandle();
22 }
23
24 43350 Mutex::Status Mutex::take() {
25 43350 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
26 43350 return this->m_delegate.take();
27 }
28
29 43277 Mutex::Status Mutex::release() {
30 43277 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
31 43277 return this->m_delegate.release();
32 }
33
34 43346 void Mutex::lock() {
35 43346 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
36 43346 Mutex::Status status = this->take();
37 43337 FW_ASSERT(status == Mutex::Status::OP_OK,
38 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(this)), status);
39 43337 }
40
41 43230 void Mutex::unLock() {
42 43230 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
43 43230 Mutex::Status status = this->release();
44 43318 FW_ASSERT(status == Mutex::Status::OP_OK,
45 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(this)), status);
46 43318 }
47
48 28637 ScopeLock::ScopeLock(Mutex& mutex) : m_mutex(mutex) {
49 28637 this->m_mutex.lock();
50 28628 }
51
52 28576 ScopeLock::~ScopeLock() {
53 28576 this->m_mutex.unLock();
54 28601 }
55
56 } // namespace Os
57