LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/base - timer_impl.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 9 9 100.0 %
Date: 2026-11-09 02:10:49 Functions: 5 5 100.0 %
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 BASE_TIMER_IMPL_H_
       7             : #define BASE_TIMER_IMPL_H__
       8             : 
       9             : #include <boost/asio/steady_timer.hpp>
      10             : #include <boost/chrono.hpp>
      11             : 
      12             : class TimerImpl {
      13             : public:
      14             :     typedef boost::asio::steady_timer TimerType;
      15             : 
      16      354036 :     TimerImpl(boost::asio::io_context &io_service)
      17      354036 :             : timer_(io_service) {
      18      354035 :     }
      19             : 
      20     4431270 :     void expires_from_now(uint64_t ms, boost::system::error_code &ec) {
      21             : #if __cplusplus >= 201103L 
      22     4431270 :         timer_.expires_from_now(std::chrono::milliseconds(ms), ec);
      23             : #else
      24             :         timer_.expires_from_now(boost::chrono::milliseconds(ms), ec);
      25             : #endif
      26     4431803 :     }
      27             : 
      28         729 :     TimerType::duration expires_from_now() {
      29         729 :         return timer_.expires_from_now();
      30             :     }
      31             : 
      32             :     template <typename WaitHandler>
      33     4508310 :     void async_wait(WaitHandler handler) { timer_.async_wait(handler); }
      34             :     void cancel(boost::system::error_code &ec) { timer_.cancel(ec); }
      35             : 
      36             : private:
      37             :     TimerType timer_;
      38             : };
      39             : 
      40             : #endif  // BASE_TIMER_IMPL_H__

Generated by: LCOV version 1.14