GCC Code Coverage Report


Directory: Os/
File: Mutex.cpp
Date: 2026-09-03 21:15:10
Exec Total Coverage
Lines: 23 32 71.9%
Functions: 6 9 66.7%
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 360 times.
✓ Branch 11 taken 5 times.
✓ Branch 17 taken 5 times.
365 Mutex::Mutex() : m_handle_storage(), m_delegate(*MutexInterface::getDelegate(m_handle_storage)) {
11 5 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
12 5 }
13
14 10 Mutex::~Mutex() {
15 10 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
16 10 m_delegate.~MutexInterface();
17 10 }
18
19 MutexHandle* Mutex::getHandle() {
20 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
21 return this->m_delegate.getHandle();
22 }
23
24 1 Mutex::Status Mutex::take() {
25 1 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
26 1 return this->m_delegate.take();
27 }
28
29 1 Mutex::Status Mutex::release() {
30 1 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
31 1 return this->m_delegate.release();
32 }
33
34 1 void Mutex::lock() {
35 1 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
36 1 Mutex::Status status = this->take();
37 1 FW_ASSERT(status == Mutex::Status::OP_OK,
38 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(this)), status);
39 1 }
40
41 1 void Mutex::unLock() {
42 1 FW_ASSERT(&this->m_delegate == reinterpret_cast<MutexInterface*>(&this->m_handle_storage[0]));
43 1 Mutex::Status status = this->release();
44 1 FW_ASSERT(status == Mutex::Status::OP_OK,
45 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(this)), status);
46 1 }
47
48 ScopeLock::ScopeLock(Mutex& mutex) : m_mutex(mutex) {
49 this->m_mutex.lock();
50 }
51
52 ScopeLock::~ScopeLock() {
53 this->m_mutex.unLock();
54 }
55
56 } // namespace Os
57