LCOV - code coverage report
Current view: top level - libs/bsw/asyncFreeRtos/include/async - Lock.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 4 4
Test Date: 2026-06-18 08:29:03 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /********************************************************************************
       2              :  * Copyright (c) 2024 Accenture
       3              :  *
       4              :  * This program and the accompanying materials are made available under the
       5              :  * terms of the Apache License Version 2.0 which is available at
       6              :  * https://www.apache.org/licenses/LICENSE-2.0
       7              :  *
       8              :  * SPDX-License-Identifier: Apache-2.0
       9              :  ********************************************************************************/
      10              : 
      11              : /**
      12              :  * \ingroup async
      13              :  */
      14              : #pragma once
      15              : 
      16              : #include "interrupts/suspendResumeAllInterrupts.h"
      17              : 
      18              : namespace async
      19              : {
      20              : /**
      21              :  * A synchronization mechanism that blocks threads from accessing a resource.
      22              :  *
      23              :  * The Lock class ensures mutual exclusion, allowing only one thread to access a
      24              :  * protected resource or function at a time. When a thread acquires the lock,
      25              :  * any other thread attempting to acquire it is blocked until the lock is released.
      26              :  * The lock is automatically released in the destructor (RAII idiom).
      27              :  */
      28              : class Lock
      29              : {
      30              : public:
      31              :     Lock();
      32              :     ~Lock();
      33              : 
      34              : private:
      35              :     OldIntEnabledStatusValueType _oldIntEnabledStatusValue;
      36              : };
      37              : 
      38              : /**
      39              :  * Inline implementations.
      40              :  */
      41          459 : inline Lock::Lock()
      42          459 : : _oldIntEnabledStatusValue(getOldIntEnabledStatusValueAndSuspendAllInterrupts())
      43          459 : {}
      44              : 
      45          459 : inline Lock::~Lock() { resumeAllInterrupts(_oldIntEnabledStatusValue); }
      46              : 
      47              : } // namespace async
        

Generated by: LCOV version 2.0-1