LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/base - task_trigger.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 13 21 61.9 %
Date: 2026-11-16 02:06:09 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef __ctrlplane__task_trigger__
       7             : #define __ctrlplane__task_trigger__
       8             : 
       9             : #include <atomic>
      10             : 
      11             : #include <boost/function.hpp>
      12             : 
      13             : class TaskTrigger {
      14             : public:
      15             :     typedef boost::function<bool()> FunctionPtr;
      16             :     TaskTrigger(const FunctionPtr& func, int task_id, int task_instance);
      17             :     ~TaskTrigger();
      18             :     void Set();
      19             :     void Reset();
      20             :     // For Test only
      21          23 :     void set_disable() {
      22          23 :         bool current = disabled_.exchange(true);
      23          23 :         assert(!current);
      24          23 :     }
      25          23 :     void set_enable() {
      26          23 :         bool current = disabled_.exchange(false);
      27          23 :         assert(current);
      28          23 :         Set();
      29          23 :     }
      30     1847892 :     bool disabled() {
      31     1847892 :         return disabled_;
      32             :     }
      33             : 
      34             :     // For Test only
      35           0 :     void set_deferred() {
      36           0 :         bool current = deferred_.exchange(true);
      37           0 :         assert(!current);
      38           0 :     }
      39           0 :     void clear_deferred() {
      40           0 :         bool current = deferred_.exchange(false);
      41           0 :         assert(current);
      42           0 :     }
      43     1847446 :     bool deferred() const { return deferred_; }
      44       13326 :     bool IsSet() const { return trigger_; }
      45             : 
      46             : private:
      47             :     class WorkerTask;
      48             : 
      49             :     FunctionPtr func_;
      50             :     int task_id_;
      51             :     int task_instance_;
      52             :     std::atomic<bool> trigger_;
      53             :     std::atomic<bool> disabled_;
      54             :     std::atomic<bool> deferred_;
      55             : };
      56             : 
      57             : #endif /* defined(__ctrlplane__task_trigger__) */

Generated by: LCOV version 1.14