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

            Line data    Source code
       1              : // Copyright 2024 Accenture.
       2              : 
       3              : #include "async/FutureSupport.h"
       4              : 
       5              : #include <async/AsyncBinding.h>
       6              : 
       7              : #include <etl/error_handler.h>
       8              : 
       9              : namespace async
      10              : {
      11              : static EventBits_t const FUTURE_SUPPORT_BITS_TO_WAIT = 0x01U;
      12              : 
      13            1 : FutureSupport::FutureSupport(ContextType const context) : _context(context)
      14              : {
      15            1 :     _eventGroupHandle = xEventGroupCreateStatic(&_eventGroup);
      16            1 : }
      17              : 
      18            2 : void FutureSupport::wait()
      19              : {
      20            2 :     TickType_t const waitEventsTickCount = (AsyncBinding::AdapterType::getCurrentTaskContext()
      21              :                                             == AsyncBinding::AdapterType::TASK_IDLE)
      22            2 :                                                ? 0U
      23            2 :                                                : AsyncBinding::WAIT_EVENTS_TICK_COUNT;
      24              :     while (true)
      25              :     {
      26            4 :         if (xEventGroupWaitBits(
      27              :                 _eventGroupHandle, FUTURE_SUPPORT_BITS_TO_WAIT, pdTRUE, pdTRUE, waitEventsTickCount)
      28            4 :             == FUTURE_SUPPORT_BITS_TO_WAIT)
      29              :         {
      30            2 :             return;
      31              :         }
      32              :     }
      33              : }
      34              : 
      35            2 : void FutureSupport::notify()
      36              : {
      37              :     BaseType_t* const higherPriorityTaskWoken
      38            2 :         = AsyncBinding::AdapterType::getHigherPriorityTaskWoken();
      39            2 :     if (higherPriorityTaskWoken == nullptr)
      40              :     {
      41            1 :         (void)xEventGroupSetBits(_eventGroupHandle, FUTURE_SUPPORT_BITS_TO_WAIT);
      42              :     }
      43              :     else
      44              :     {
      45            1 :         (void)xEventGroupSetBitsFromISR(
      46              :             _eventGroupHandle, FUTURE_SUPPORT_BITS_TO_WAIT, higherPriorityTaskWoken);
      47              :     }
      48            2 : }
      49              : 
      50            2 : void FutureSupport::assertTaskContext()
      51              : {
      52            2 :     ETL_ASSERT(verifyTaskContext(), ETL_ERROR_GENERIC("task context not verified"));
      53            1 : }
      54              : 
      55            4 : bool FutureSupport::verifyTaskContext()
      56              : {
      57            4 :     return _context == AsyncBinding::AdapterType::getCurrentTaskContext();
      58              : }
      59              : 
      60              : } // namespace async
        

Generated by: LCOV version 2.0-1