• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef TIME_UTILS_H_
6 #define TIME_UTILS_H_
7 
8 #include <stdint.h>
9 
10 namespace time_utils {
11 
12 uint64_t GetTimestamp();
13 
14 class PeriodicTimer {
15  public:
16   PeriodicTimer(int interval_ms);
17   ~PeriodicTimer();
18 
19   void Start();
20   void Stop();
21   // Wait for next tick. Returns false if interrupted by Stop() or not started.
22   bool Wait();
23 
24  private:
25   PeriodicTimer(const PeriodicTimer&) = delete;
26   void operator=(const PeriodicTimer&) = delete;
27 
28   const int interval_ms_;
29   int timer_fd_;
30 };
31 
32 }  // namespace time_utils
33 
34 #endif  // TIME_UTILS_
35