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) Lumiera.org
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
33 #include "vault/real-clock.hpp"
34 
35 #include <chrono>
36 
37 
38 using lib::time::FSecs;
39 using std::chrono::steady_clock;
40 using std::chrono::microseconds;
41 using std::chrono::floor;
42 
43 namespace vault {
44 
45 
46 
48  const Offset RealClock::CONSIDERED_RECENT{FSecs {1,1000}};
49 
50 
51  TimeValue
52  RealClock::_readSystemTime()
53  {
54  auto now = steady_clock::now();
55  auto microTicks = floor<microseconds> (now.time_since_epoch())
56  .count();
57 
58  ENSURE (microTicks == _raw(TimeValue{microTicks}));
59  return TimeValue::buildRaw_(microTicks); // bypassing the limit check
60  }
61 
62 
63 
64 } // namespace vault
static TimeValue buildRaw_(gavl_time_t)
Definition: time.cpp:245
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:229
static const Offset CONSIDERED_RECENT
events during the last ms are considered "recent" for the purpose of testing
Definition: real-clock.hpp:77
Front-end for simplified access to the current wall clock time.
Vault-Layer implementation namespace root.