LCOV - code coverage report
Current view: top level - source/common/quic - envoy_quic_clock.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 8 12 66.7 %
Date: 2024-01-05 06:35:25 Functions: 2 3 66.7 %

          Line data    Source code
       1             : #include "source/common/quic/envoy_quic_clock.h"
       2             : 
       3             : namespace Envoy {
       4             : namespace Quic {
       5             : 
       6       17348 : quic::QuicTime EnvoyQuicClock::ApproximateNow() const {
       7       17348 :   return quic::QuicTime::Zero() + quic::QuicTime::Delta::FromMicroseconds(microsecondsSinceEpoch(
       8       17348 :                                       dispatcher_.approximateMonotonicTime()));
       9       17348 : }
      10             : 
      11        3270 : quic::QuicTime EnvoyQuicClock::Now() const {
      12             :   // Since the expensive operation of obtaining time has to be performed anyway,
      13             :   // make Dispatcher update approximate time. Without this, alarms might fire
      14             :   // one event loop later. const_cast is necessary here because
      15             :   // updateApproximateMonotonicTime() is a non-const operation, and Now() is
      16             :   // conceptually const (even though this particular implementation has a
      17             :   // visible side effect). Changing Now() to non-const would necessitate
      18             :   // changing a number of other methods and members to non-const, which would
      19             :   // not increase clarity.
      20        3270 :   const_cast<Event::Dispatcher&>(dispatcher_).updateApproximateMonotonicTime();
      21        3270 :   return ApproximateNow();
      22        3270 : }
      23             : 
      24           0 : quic::QuicWallTime EnvoyQuicClock::WallNow() const {
      25           0 :   return quic::QuicWallTime::FromUNIXMicroseconds(
      26           0 :       microsecondsSinceEpoch(dispatcher_.timeSource().systemTime()));
      27           0 : }
      28             : 
      29             : } // namespace Quic
      30             : } // namespace Envoy

Generated by: LCOV version 1.15