YARP
Yet Another Robot Platform
SystemClock.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #include <yarp/conf/system.h>
7 
8 #include <yarp/os/SystemClock.h>
9 
10 #include <chrono>
11 #include <thread>
12 
13 
15 {
16  return nowSystem();
17 }
18 
19 void yarp::os::SystemClock::delay(double seconds)
20 {
21  delaySystem(seconds);
22 }
23 
25 {
26  return true;
27 }
28 
30 {
31  std::this_thread::sleep_for(std::chrono::duration<double>(seconds));
32 }
33 
35 {
36  return std::chrono::time_point_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now()).time_since_epoch().count();
37 }
double now() override
Return the current time in seconds, relative to an arbitrary starting point.
Definition: SystemClock.cpp:14
static double nowSystem()
Definition: SystemClock.cpp:34
void delay(double seconds) override
Wait for a certain number of seconds.
Definition: SystemClock.cpp:19
bool isValid() const override
Check if time is valid (non-zero).
Definition: SystemClock.cpp:24
static void delaySystem(double seconds)
Definition: SystemClock.cpp:29
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:121