Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
common
utilities
time
periodic_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 "
timer.h
"
8
9
namespace
utilities
10
{
11
namespace
time
12
{
13
// A timer class that wakes up every <delta> seconds/minutes/etc. on its bool operator:
14
// Usage example:
15
// periodic_timer timer( chrono::seconds( 5 ));
16
// while(1) {
17
// if( timer ) { /* do something every 5 seconds */ }
18
// }
19
class
periodic_timer
20
{
21
public
:
22
23
periodic_timer
(clock::duration delta)
24
:
_delta
(delta)
25
{
26
}
27
28
// Allow use of bool operator for checking time expiration and re trigger when time expired
29
operator
bool()
const
30
{
31
if
(
_delta
.
has_expired
())
32
{
33
_delta
.
start
();
34
return
true
;
35
}
36
return
false
;
37
}
38
39
// Force time expiration
40
void
set_expired
()
41
{
42
_delta
.
set_expired
();
43
}
44
protected
:
45
timer
_delta
;
46
};
47
}
48
}
utilities::time::periodic_timer
Definition:
periodic_timer.h:19
utilities::time::timer::start
void start() const
Definition:
timer.h:24
utilities::time::timer::set_expired
void set_expired()
Definition:
timer.h:36
timer.h
utilities::time::periodic_timer::periodic_timer
periodic_timer(clock::duration delta)
Definition:
periodic_timer.h:23
utilities::time::timer
Definition:
timer.h:15
utilities::time::timer::has_expired
bool has_expired() const
Definition:
timer.h:30
utilities::time::periodic_timer::set_expired
void set_expired()
Definition:
periodic_timer.h:40
utilities::time::periodic_timer::_delta
timer _delta
Definition:
periodic_timer.h:45
utilities
Definition:
wrap.cpp:11
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:47:39