LCOV - code coverage report
Current view: top level - libs/bsw/asyncFreeRtos/include/async - StaticRunnable.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 9 9
Test Date: 2026-02-24 11:21:15 Functions: 100.0 % 8 8

            Line data    Source code
       1              : // Copyright 2024 Accenture.
       2              : 
       3              : /**
       4              :  * \ingroup async
       5              :  */
       6              : #pragma once
       7              : 
       8              : namespace async
       9              : {
      10              : /**
      11              :  * This is a template class that acts as collection (linked list)
      12              :  * of Tasks to be added to the FreeRTOS system.
      13              :  *
      14              :  * \tparam T The underlying implementing execute function.
      15              :  */
      16              : 
      17              : template<class T>
      18              : class StaticRunnable
      19              : {
      20              : protected:
      21              :     ~StaticRunnable() = default;
      22              : 
      23              : public:
      24              :     StaticRunnable();
      25              : 
      26              :     static void run();
      27              : 
      28              : private:
      29              :     T* _next;
      30              : 
      31              :     static T* _first;
      32              : };
      33              : 
      34              : template<class T>
      35              : T* StaticRunnable<T>::_first = nullptr;
      36              : 
      37              : /**
      38              :  * Class constructor.
      39              :  * On instance construction the new instance is added into
      40              :  * the inked list by adjusting the pointers _first and _next.
      41              :  */
      42              : template<class T>
      43           20 : StaticRunnable<T>::StaticRunnable() : _next(_first)
      44              : {
      45           20 :     _first = static_cast<T*>(this);
      46           20 : }
      47              : 
      48              : template<class T>
      49           20 : void StaticRunnable<T>::run()
      50              : {
      51           40 :     while (_first != nullptr)
      52              :     {
      53           20 :         T* const current = _first;
      54           20 :         _first           = _first->_next;
      55           20 :         current->execute();
      56              :     }
      57           20 : }
      58              : 
      59              : } // namespace async
        

Generated by: LCOV version 2.0-1