rippled
Loading...
Searching...
No Matches
abstract_clock.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of Beast: https://github.com/vinniefalco/Beast
4 Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef BEAST_CHRONO_ABSTRACT_CLOCK_H_INCLUDED
21#define BEAST_CHRONO_ABSTRACT_CLOCK_H_INCLUDED
22
23namespace beast {
24
53template <class Clock>
55{
56public:
57 using rep = typename Clock::rep;
58 using period = typename Clock::period;
59 using duration = typename Clock::duration;
60 using time_point = typename Clock::time_point;
61 using clock_type = Clock;
62
63 static bool const is_steady = Clock::is_steady;
64
65 virtual ~abstract_clock() = default;
66 abstract_clock() = default;
67 abstract_clock(abstract_clock const&) = default;
68
70 [[nodiscard]] virtual time_point
71 now() const = 0;
72};
73
74//------------------------------------------------------------------------------
75
76namespace detail {
77
78template <class Facade, class Clock>
80{
81 explicit abstract_clock_wrapper() = default;
82
85
87 now() const override
88 {
89 return Clock::now();
90 }
91};
92
93} // namespace detail
94
95//------------------------------------------------------------------------------
96
102template <class Facade, class Clock = Facade>
103abstract_clock<Facade>&
105{
107 return clock;
108}
109
110} // namespace beast
111
112#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.