LCOV - code coverage report
Current view: top level - asyncFreeRtos/include/async - Lock.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 3 100.0 %
Date: 2025-04-15 08:32:23 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2024 Accenture.
       2             : 
       3             : /**
       4             :  * \ingroup async
       5             :  */
       6             : #pragma once
       7             : 
       8             : #include "interrupts/suspendResumeAllInterrupts.h"
       9             : 
      10             : namespace async
      11             : {
      12             : /**
      13             :  * A synchronization mechanism that blocks threads from accessing a resource.
      14             :  *
      15             :  * The Lock class ensures mutual exclusion, allowing only one thread to access a
      16             :  * protected resource or function at a time. When a thread acquires the lock,
      17             :  * any other thread attempting to acquire it is blocked until the lock is released.
      18             :  * The lock is automatically released in the destructor (RAII idiom).
      19             :  */
      20             : class Lock
      21             : {
      22             : public:
      23             :     Lock();
      24             :     ~Lock();
      25             : 
      26             : private:
      27             :     OldIntEnabledStatusValueType _oldIntEnabledStatusValue;
      28             : };
      29             : 
      30             : /**
      31             :  * Inline implementations.
      32             :  */
      33         459 : inline Lock::Lock()
      34         459 : : _oldIntEnabledStatusValue(getOldIntEnabledStatusValueAndSuspendAllInterrupts())
      35             : {}
      36             : 
      37         459 : inline Lock::~Lock() { resumeAllInterrupts(_oldIntEnabledStatusValue); }
      38             : 
      39             : } // namespace async

Generated by: LCOV version 1.14