RobotsIO
Loading...
Searching...
No Matches
Clock.cpp
1/*
2 * Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#include <RobotsIO/Utils/Clock.h>
9
10#include <chrono>
11#include <thread>
12
13using namespace RobotsIO::Utils;
14
15
16Clock::~Clock()
17{}
18
19
20double Clock::now() const
21{
22 auto current_time = std::chrono::steady_clock::now();
23 auto since_epoch = std::chrono::duration<double>(current_time.time_since_epoch());
24 return since_epoch.count();
25}
26
27
28void Clock::delay(const int& milliseconds) const
29{
30 std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
31}