Lumiera  0.pre.03
»edit your freedom«
real-clock.cpp
Go to the documentation of this file.
1 /*
2  RealClock - convenience front-end to access the system clock
3 
4  Copyright (C)
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
24 #include "vault/real-clock.hpp"
25 
26 #include <chrono>
27 
28 
29 using lib::time::FSecs;
30 using std::chrono::steady_clock;
31 using std::chrono::microseconds;
32 using std::chrono::floor;
33 
34 namespace vault {
35 
36 
37 
39  const Offset RealClock::CONSIDERED_RECENT{FSecs {1,1000}};
40 
41 
42  TimeValue
43  RealClock::_readSystemTime()
44  {
45  auto now = steady_clock::now();
46  auto microTicks = floor<microseconds> (now.time_since_epoch())
47  .count();
48 
49  ENSURE (microTicks == _raw(TimeValue{microTicks}));
50  return TimeValue::buildRaw_(microTicks); // bypassing the limit check
51  }
52 
53 
54 
55 } // namespace vault
static TimeValue buildRaw_(gavl_time_t)
Definition: time.cpp:236
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:220
static const Offset CONSIDERED_RECENT
events during the last ms are considered "recent" for the purpose of testing
Definition: real-clock.hpp:68
Front-end for simplified access to the current wall clock time.
Vault-Layer implementation namespace root.