LCOV - code coverage report
Current view: top level - vnsw/agent/services/multicast/agent_map - task_thread_api.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 44 45 97.8 %
Date: 2026-11-09 02:10:49 Functions: 11 11 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifdef __cplusplus
       7             : extern "C" {
       8             : #endif
       9             : #include "task_thread_api.h"
      10             : #ifdef __cplusplus
      11             : }
      12             : #endif
      13             : 
      14        4559 : void thread_new_circular_thread(task_thread *head)
      15             : {
      16        4559 :     if (!head) {
      17           0 :         return;
      18             :     }
      19             : 
      20        4559 :     head->next = head;
      21        4559 :     head->prev = head;
      22             : 
      23        4559 :     return;
      24             : }
      25             : 
      26        2883 : boolean thread_circular_thread_empty(task_thread *head)
      27             : {
      28        2883 :     return (head->next == head) ? TRUE : FALSE;
      29             : }
      30             : 
      31       11725 : boolean thread_circular_thread_head(task_thread *head, task_thread *node)
      32             : {
      33       11725 :     return (head == node) ? TRUE : FALSE;
      34             : }
      35             : 
      36        2268 : boolean thread_node_on_thread(const task_thread *node)
      37             : {
      38        2268 :     return (node->next) ? TRUE : FALSE;
      39             : }
      40             : 
      41        4287 : task_thread *thread_circular_top(task_thread *head)
      42             : {
      43        4287 :     if (head->next == head) {
      44        3622 :         return NULL;
      45             :     }
      46             : 
      47         665 :     return head->next;
      48             : }
      49             : 
      50        3723 : void thread_circular_add_top(task_thread *head, task_thread *node)
      51             : {
      52        3723 :     node->next = head->next;
      53        3723 :     node->prev = head;
      54        3723 :     head->next = node;
      55        3723 :     node->next->prev = node;
      56             : 
      57        3723 :     return;
      58             : }
      59             : 
      60        1165 : void thread_circular_add_bottom(task_thread *head, task_thread *node)
      61             : {
      62        1165 :     thread_circular_add_top(head->prev, node);
      63        1165 : }
      64             : 
      65       11725 : task_thread *thread_next_node(task_thread *node)
      66             : {
      67       11725 :     return node->next;
      68             : }
      69             : 
      70        1305 : task_thread *thread_circular_thread_next(task_thread *head, task_thread *node)
      71             : {
      72        1305 :     if (!node) {
      73        1100 :         return (head->next == head) ? NULL : head->next;
      74             :     }
      75             : 
      76         205 :     return (node->next == head) ? NULL : node->next;
      77             : }
      78             : 
      79        6083 : void thread_remove(task_thread *node)
      80             : {
      81        6083 :     if (!node->next) {
      82        2360 :         return;
      83             :     }
      84             : 
      85        3723 :     node->next->prev = node->prev;
      86        3723 :     node->prev->next = node->next;
      87             : 
      88        3723 :     node->next = NULL;
      89        3723 :     node->prev = NULL;
      90             : }
      91             : 
      92         945 : task_thread *thread_circular_dequeue_top(task_thread *head)
      93             : {
      94         945 :     task_thread *current = NULL;
      95             : 
      96         945 :     if (head->next == head) {
      97         497 :         return NULL;
      98             :     }
      99             : 
     100         448 :     current = head->next;
     101         448 :     thread_remove(current);
     102             : 
     103         448 :     return current;
     104             : }
     105             : 

Generated by: LCOV version 1.14