rippled
ManualTimeKeeper.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
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 RIPPLE_TEST_MANUALTIMEKEEPER_H_INCLUDED
21 #define RIPPLE_TEST_MANUALTIMEKEEPER_H_INCLUDED
22 
23 #include <ripple/core/TimeKeeper.h>
24 #include <mutex>
25 
26 namespace ripple {
27 namespace test {
28 
30 {
31 public:
33 
34  void
35  run(std::vector<std::string> const& servers) override;
36 
38  now() const override;
39 
41  closeTime() const override;
42 
43  void
45 
47  nowOffset() const override;
48 
50  closeOffset() const override;
51 
52  void
54 
55 private:
56  // Adjust system_clock::time_point for NetClock epoch
57  static time_point
58  adjust(std::chrono::system_clock::time_point when);
59 
60  std::mutex mutable mutex_;
63 };
64 
65 } // namespace test
66 } // namespace ripple
67 
68 #endif
ripple::test::ManualTimeKeeper::run
void run(std::vector< std::string > const &servers) override
Launch the internal thread.
Definition: ManualTimeKeeper.cpp:32
ripple::test::ManualTimeKeeper::ManualTimeKeeper
ManualTimeKeeper()
Definition: ManualTimeKeeper.cpp:27
std::vector< std::string >
std::chrono::duration< std::int32_t >
ripple::test::ManualTimeKeeper::closeTime
time_point closeTime() const override
Returns the close time, in network time.
Definition: ManualTimeKeeper.cpp:44
ripple::test::ManualTimeKeeper::nowOffset
std::chrono::duration< std::int32_t > nowOffset() const override
Definition: ManualTimeKeeper.cpp:68
ripple::test::ManualTimeKeeper
Definition: ManualTimeKeeper.h:29
ripple::test::ManualTimeKeeper::closeOffset
std::chrono::duration< std::int32_t > closeOffset() const override
Definition: ManualTimeKeeper.cpp:74
ripple::test::ManualTimeKeeper::adjust
static time_point adjust(std::chrono::system_clock::time_point when)
Definition: ManualTimeKeeper.cpp:88
ripple::test::ManualTimeKeeper::mutex_
std::mutex mutex_
Definition: ManualTimeKeeper.h:60
ripple::test::ManualTimeKeeper::now_
time_point now_
Definition: ManualTimeKeeper.h:62
std::chrono::time_point
ripple::TimeKeeper
Manages various times used by the server.
Definition: TimeKeeper.h:32
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::test::ManualTimeKeeper::adjustCloseTime
void adjustCloseTime(std::chrono::duration< std::int32_t > amount) override
Adjust the close time.
Definition: ManualTimeKeeper.cpp:51
mutex
ripple::test::ManualTimeKeeper::now
time_point now() const override
Returns the estimate of wall time, in network time.
Definition: ManualTimeKeeper.cpp:37
ripple::test::ManualTimeKeeper::set
void set(time_point now)
Definition: ManualTimeKeeper.cpp:81
ripple::test::ManualTimeKeeper::closeOffset_
std::chrono::duration< std::int32_t > closeOffset_
Definition: ManualTimeKeeper.h:61