Coverage Report

Created: 2026-07-26 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gbmcweb/tlbmc/time/clock.h
Line
Count
Source
1
/*
2
 * Copyright 2020 Google LLC
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
// This library defines a simplified clock interface that wraps the abseil
18
// functions for looking at the current time. This is intended to enable more
19
// testability in code that needs to track the current time by allowing you to
20
// supply fake/mock clocks that give the test control over when time advances.
21
22
#ifndef THIRD_PARTY_ECCLESIA_LIB_TIME_CLOCK_H_
23
#define THIRD_PARTY_ECCLESIA_LIB_TIME_CLOCK_H_
24
25
#include "absl/time/clock.h"
26
#include "absl/time/time.h"
27
28
namespace ecclesia {
29
30
class Clock {
31
 public:
32
  // Return a pointer to a global thread-safe singleton clock implemented using
33
  // the actual abseil time functions.
34
  static Clock* RealClock();
35
36
0
  virtual ~Clock() = default;
37
38
  virtual void Sleep(absl::Duration d) = 0;
39
40
  // Returns current time.
41
  virtual absl::Time Now() const = 0;
42
};
43
44
}  // namespace ecclesia
45
46
#endif  // THIRD_PARTY_ECCLESIA_LIB_TIME_CLOCK_H_