rippled
Loading...
Searching...
No Matches
include
xrpl
basics
UptimeClock.h
1
#pragma once
2
3
#include <
atomic
>
4
#include <
chrono
>
5
#include <
ratio
>
6
#include <
thread
>
7
8
namespace
xrpl
{
9
17
class
UptimeClock
18
{
19
public
:
20
using
rep
= int;
21
using
period
=
std::ratio<1>
;
22
using
duration
=
std::chrono::duration<rep, period>
;
23
using
time_point
=
std::chrono::time_point<UptimeClock>
;
24
static
constexpr
bool
is_steady
= std::chrono::system_clock::is_steady;
25
26
explicit
UptimeClock
() =
default
;
27
28
static
time_point
29
now
();
// seconds since rippled program start
30
31
private
:
32
static
std::atomic<rep>
now_
;
33
static
std::atomic<bool>
stop_
;
34
35
struct
update_thread
:
private
std::thread
36
{
37
~update_thread
();
38
update_thread
(
update_thread
&&) =
default
;
39
40
using
std::thread::thread
;
41
};
42
43
static
update_thread
44
start_clock
();
45
};
46
47
}
// namespace xrpl
atomic
chrono
xrpl::UptimeClock
Tracks program uptime to seconds precision.
Definition
UptimeClock.h:18
xrpl::UptimeClock::is_steady
static constexpr bool is_steady
Definition
UptimeClock.h:24
xrpl::UptimeClock::now_
static std::atomic< rep > now_
Definition
UptimeClock.h:32
xrpl::UptimeClock::rep
int rep
Definition
UptimeClock.h:20
xrpl::UptimeClock::start_clock
static update_thread start_clock()
Definition
UptimeClock.cpp:26
xrpl::UptimeClock::now
static time_point now()
Definition
UptimeClock.cpp:48
xrpl::UptimeClock::UptimeClock
UptimeClock()=default
xrpl::UptimeClock::stop_
static std::atomic< bool > stop_
Definition
UptimeClock.h:33
std::chrono::duration< rep, period >
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
ratio
xrpl::UptimeClock::update_thread
Definition
UptimeClock.h:36
xrpl::UptimeClock::update_thread::~update_thread
~update_thread()
Definition
UptimeClock.cpp:13
xrpl::UptimeClock::update_thread::update_thread
update_thread(update_thread &&)=default
thread
std::chrono::time_point
Generated by
1.9.8