timer.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 // Helper classes to keep track of time
5 #pragma once
6 
7 #include "stopwatch.h"
8 
9 namespace utilities
10 {
11  namespace time
12  {
13  // A timer counting backwards in time (vs forwards in the `stopwatch` class)
14  // It supply basic timer API, start, has_expired..
15  class timer
16  {
17  public:
18 
19  timer(clock::duration timeout) : _delta(timeout), sw()
20  {
21  }
22 
23  // Start timer
24  void start() const
25  {
26  sw.reset();
27  }
28 
29  // Check if timer time expired
30  bool has_expired() const
31  {
32  return sw.get_start() + _delta <= clock::now();
33  }
34 
35  // Force time expiration
36  void set_expired()
37  {
39  }
40  protected:
41  clock::duration _delta;
43  };
44  }
45 }
void start() const
Definition: timer.h:24
void set_expired()
Definition: timer.h:36
stopwatch sw
Definition: timer.h:42
timer(clock::duration timeout)
Definition: timer.h:19
clock::time_point get_start() const
Definition: stopwatch.h:42
void reset(clock::time_point start_time=clock::now()) const
Definition: stopwatch.h:24
bool has_expired() const
Definition: timer.h:30
std::chrono::duration< uint64_t, std::nano > nanoseconds
clock::duration _delta
Definition: timer.h:41
GLbitfield GLuint64 timeout


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11