LCOV - code coverage report
Current view: top level - asyncFreeRtos/src/async - FutureSupport.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 20 100.0 %
Date: 2025-01-20 13:53:09 Functions: 5 5 100.0 %

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

Generated by: LCOV version 1.14