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-09-28 02:13:17 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             :  */
       4             : 
       5             : #ifndef __ctrlplane__task_trigger__
       6             : #define __ctrlplane__task_trigger__
       7             : 
       8             : #include <atomic>
       9             : 
      10             : #include <boost/function.hpp>
      11             : 
      12             : class TaskTrigger {
      13             : public:
      14             :     typedef boost::function<bool()> FunctionPtr;
      15             :     TaskTrigger(const FunctionPtr& func, int task_id, int task_instance);
      16             :     ~TaskTrigger();
      17             :     void Set();
      18             :     void Reset();
      19             :     // For Test only
      20          23 :     void set_disable() {
      21          23 :         bool current = disabled_.exchange(true);
      22          23 :         assert(!current);
      23          23 :     }
      24          23 :     void set_enable() {
      25          23 :         bool current = disabled_.exchange(false);
      26          23 :         assert(current);
      27          23 :         Set();
      28          23 :     }
      29     1806304 :     bool disabled() {
      30     1806304 :         return disabled_;
      31             :     }
      32             : 
      33             :     // For Test only
      34           0 :     void set_deferred() {
      35           0 :         bool current = deferred_.exchange(true);
      36           0 :         assert(!current);
      37           0 :     }
      38           0 :     void clear_deferred() {
      39           0 :         bool current = deferred_.exchange(false);
      40           0 :         assert(current);
      41           0 :     }
      42     1805850 :     bool deferred() const { return deferred_; }
      43       22014 :     bool IsSet() const { return trigger_; }
      44             : 
      45             : private:
      46             :     class WorkerTask;
      47             : 
      48             :     FunctionPtr func_;
      49             :     int task_id_;
      50             :     int task_instance_;
      51             :     std::atomic<bool> trigger_;
      52             :     std::atomic<bool> disabled_;
      53             :     std::atomic<bool> deferred_;
      54             : };
      55             : 
      56             : #endif /* defined(__ctrlplane__task_trigger__) */

Generated by: LCOV version 1.14