rippled
Loading...
Searching...
No Matches
abstract_clock.h
1#ifndef BEAST_CHRONO_ABSTRACT_CLOCK_H_INCLUDED
2#define BEAST_CHRONO_ABSTRACT_CLOCK_H_INCLUDED
3
4namespace beast {
5
34template <class Clock>
36{
37public:
38 using rep = typename Clock::rep;
39 using period = typename Clock::period;
40 using duration = typename Clock::duration;
41 using time_point = typename Clock::time_point;
42 using clock_type = Clock;
43
44 static bool const is_steady = Clock::is_steady;
45
46 virtual ~abstract_clock() = default;
47 abstract_clock() = default;
48 abstract_clock(abstract_clock const&) = default;
49
51 [[nodiscard]] virtual time_point
52 now() const = 0;
53};
54
55//------------------------------------------------------------------------------
56
57namespace detail {
58
59template <class Facade, class Clock>
61{
62 explicit abstract_clock_wrapper() = default;
63
66
68 now() const override
69 {
70 return Clock::now();
71 }
72};
73
74} // namespace detail
75
76//------------------------------------------------------------------------------
77
83template <class Facade, class Clock = Facade>
84abstract_clock<Facade>&
86{
88 return clock;
89}
90
91} // namespace beast
92
93#endif
Abstract interface to a clock.
typename Clock::rep rep
typename Clock::time_point time_point
static bool const is_steady
virtual ~abstract_clock()=default
typename Clock::period period
virtual time_point now() const =0
Returns the current time.
typename Clock::duration duration
abstract_clock(abstract_clock const &)=default
abstract_clock< Facade > & get_abstract_clock()
Returns a global instance of an abstract clock.
time_point now() const override
Returns the current time.