LCOV - code coverage report
Current view: top level - libs/bsw/asyncImpl/include/async - QueueNode.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 16 16
Test Date: 2026-06-18 08:29:03 Functions: 100.0 % 11 11

            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              : /**
      12              :  * \ingroup async
      13              :  */
      14              : #pragma once
      15              : 
      16              : namespace async
      17              : {
      18              : template<typename T>
      19              : class QueueNode
      20              : {
      21              : public:
      22              :     QueueNode();
      23              : 
      24              :     bool isEnqueued() const;
      25              : 
      26              :     T* getNext() const;
      27              :     void setNext(T* next);
      28              : 
      29              :     void enqueue();
      30              :     T* dequeue();
      31              : 
      32              : private:
      33              :     T* _next;
      34              : };
      35              : 
      36              : /**
      37              :  * Inline implementations.
      38              :  */
      39              : template<typename T>
      40           35 : inline QueueNode<T>::QueueNode() : _next(reinterpret_cast<T*>(1U))
      41           35 : {}
      42              : 
      43              : template<typename T>
      44           43 : inline bool QueueNode<T>::isEnqueued() const
      45              : {
      46           43 :     return _next != reinterpret_cast<T*>(1U);
      47              : }
      48              : 
      49              : template<typename T>
      50            7 : inline T* QueueNode<T>::getNext() const
      51              : {
      52            7 :     return _next;
      53              : }
      54              : 
      55              : template<typename T>
      56           14 : inline void QueueNode<T>::setNext(T* const next)
      57              : {
      58           14 :     _next = next;
      59           14 : }
      60              : 
      61              : template<typename T>
      62           24 : inline void QueueNode<T>::enqueue()
      63              : {
      64           24 :     _next = nullptr;
      65           24 : }
      66              : 
      67              : template<typename T>
      68           21 : inline T* QueueNode<T>::dequeue()
      69              : {
      70           21 :     T* const prevNext = _next;
      71           21 :     _next             = reinterpret_cast<T*>(1U);
      72           21 :     return prevNext;
      73              : }
      74              : 
      75              : } // namespace async
        

Generated by: LCOV version 2.0-1