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-06-18 08:29:03 Functions: 100.0 % 5 5

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

Generated by: LCOV version 2.0-1