This commit is contained in:
manojsdoshi
2023-11-08 18:39:32 +00:00
parent e2a2b5c865
commit c5554cfb8a
2686 changed files with 55239 additions and 53717 deletions

View File

@@ -93,93 +93,95 @@ $(function() {
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="preprocessor">#include &lt;ripple/basics/chrono.h&gt;</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="preprocessor">#include &lt;ripple/beast/clock/abstract_clock.h&gt;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/atomic.html">atomic</a>&gt;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; </div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; </div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html"> 30</a></span>&#160;<span class="keyword">class </span><a class="code" href="classripple_1_1TimeKeeper.html">TimeKeeper</a> : <span class="keyword">public</span> <a class="code" href="classbeast_1_1abstract__clock.html">beast::abstract_clock</a>&lt;NetClock&gt;</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;{</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d"> 33</a></span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic.html">std::atomic&lt;std::chrono::seconds&gt;</a> <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>{};</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; <span class="comment">// Adjust system_clock::time_point for NetClock epoch</span></div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; <span class="keyword">static</span> constexpr <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a></div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1"> 37</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1">adjust</a>(std::chrono::system_clock::time_point when)</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; {</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a>(std::chrono::duration_cast&lt;duration&gt;(</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; when.time_since_epoch() - <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">days</a>(10957)));</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; }</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <span class="keyword">virtual</span> <a class="code" href="classripple_1_1TimeKeeper.html#abd0e431f6ed68ad20061bada64314327">~TimeKeeper</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; </div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; [[nodiscard]] <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a></div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e"> 63</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e">now</a>()<span class="keyword"> const override</span></div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1">adjust</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/system_clock/now.html">std::chrono::system_clock::now</a>());</div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; }</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; </div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; [[nodiscard]] <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a></div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#ada2cee023f1dcf3c80250f8840139440"> 75</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#ada2cee023f1dcf3c80250f8840139440">closeTime</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e">now</a>() + <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; }</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; </div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; <span class="comment">// This may return a negative value</span></div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; [[nodiscard]] <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a6ea20501ef727ee3f4cd25aa9c164e26"> 82</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a6ea20501ef727ee3f4cd25aa9c164e26">closeOffset</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; }</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; </div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div>
<div class="line"><a name="l00089"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#abfc6614b53f236861e4e61e91574283e"> 89</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#abfc6614b53f236861e4e61e91574283e">adjustCloseTime</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a> by)</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; {</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; <span class="keyword">using namespace </span>std::chrono_literals;</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; </div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="keyword">auto</span> offset = <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; <span class="keywordflow">if</span> (by == 0s &amp;&amp; offset == 0s)</div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; <span class="keywordflow">return</span> offset;</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <span class="comment">// The close time adjustment is serialized externally to this</span></div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="comment">// code. The compare/exchange only serves as a weak check and</span></div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; <span class="comment">// should not fail. Even if it does, it&#39;s safe to simply just</span></div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="comment">// skip the adjustment.</span></div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange.html">compare_exchange_strong</a>(offset, [by, offset]() {</div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; <span class="comment">// Ignore small offsets and push the close time</span></div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; <span class="comment">// towards our wall time.</span></div>
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160; <span class="keywordflow">if</span> (by &gt; 1s)</div>
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160; <span class="keywordflow">return</span> offset + ((by + 3s) / 4);</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160; </div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160; <span class="keywordflow">if</span> (by &lt; -1s)</div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; <span class="keywordflow">return</span> offset + ((by - 3s) / 4);</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; </div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; <span class="keywordflow">return</span> (offset * 3) / 4;</div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; }());</div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; </div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; }</div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160;};</div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; </div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160;} <span class="comment">// namespace ripple</span></div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; </div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/atomic.html">atomic</a>&gt;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html"> 31</a></span>&#160;<span class="keyword">class </span><a class="code" href="classripple_1_1TimeKeeper.html">TimeKeeper</a> : <span class="keyword">public</span> <a class="code" href="classbeast_1_1abstract__clock.html">beast::abstract_clock</a>&lt;NetClock&gt;</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;{</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d"> 34</a></span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic.html">std::atomic&lt;std::chrono::seconds&gt;</a> <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>{};</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; </div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; <span class="comment">// Adjust system_clock::time_point for NetClock epoch</span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; <span class="keyword">static</span> constexpr <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a></div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1"> 38</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1">adjust</a>(std::chrono::system_clock::time_point when)</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; {</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a>(std::chrono::duration_cast&lt;duration&gt;(</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; when.time_since_epoch() - <a class="code" href="namespaceripple.html#ad4e2a948afe60129e9b99dc30af7a5fd">epoch_offset</a>));</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; }</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; </div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="keyword">virtual</span> <a class="code" href="classripple_1_1TimeKeeper.html#abd0e431f6ed68ad20061bada64314327">~TimeKeeper</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; [[nodiscard]] <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a></div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e"> 64</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e">now</a>()<span class="keyword"> const override</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1">adjust</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/system_clock/now.html">std::chrono::system_clock::now</a>());</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; }</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; [[nodiscard]] <a class="code" href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">time_point</a></div>
<div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#ada2cee023f1dcf3c80250f8840139440"> 76</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#ada2cee023f1dcf3c80250f8840139440">closeTime</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e">now</a>() + <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; }</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; </div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; <span class="comment">// This may return a negative value</span></div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; [[nodiscard]] <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div>
<div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#a6ea20501ef727ee3f4cd25aa9c164e26"> 83</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a6ea20501ef727ee3f4cd25aa9c164e26">closeOffset</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160;<span class="keyword"> </span>{</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; }</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; </div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div>
<div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="classripple_1_1TimeKeeper.html#abfc6614b53f236861e4e61e91574283e"> 90</a></span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#abfc6614b53f236861e4e61e91574283e">adjustCloseTime</a>(<a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a> by)</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; {</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; <span class="keyword">using namespace </span>std::chrono_literals;</div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; </div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <span class="keyword">auto</span> offset = <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; </div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; <span class="keywordflow">if</span> (by == 0s &amp;&amp; offset == 0s)</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="keywordflow">return</span> offset;</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; </div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="comment">// The close time adjustment is serialized externally to this</span></div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; <span class="comment">// code. The compare/exchange only serves as a weak check and</span></div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="comment">// should not fail. Even if it does, it&#39;s safe to simply just</span></div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; <span class="comment">// skip the adjustment.</span></div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange.html">compare_exchange_strong</a>(offset, [by, offset]() {</div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; <span class="comment">// Ignore small offsets and push the close time</span></div>
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160; <span class="comment">// towards our wall time.</span></div>
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160; <span class="keywordflow">if</span> (by &gt; 1s)</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160; <span class="keywordflow">return</span> offset + ((by + 3s) / 4);</div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160; </div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; <span class="keywordflow">if</span> (by &lt; -1s)</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; <span class="keywordflow">return</span> offset + ((by - 3s) / 4);</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; </div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; <span class="keywordflow">return</span> (offset * 3) / 4;</div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; }());</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; </div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">closeOffset_</a>.<a class="codeRef" href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">load</a>();</div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; }</div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160;};</div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; </div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160;} <span class="comment">// namespace ripple</span></div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; </div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aduration_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::duration</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a6ea20501ef727ee3f4cd25aa9c164e26"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a6ea20501ef727ee3f4cd25aa9c164e26">ripple::TimeKeeper::closeOffset</a></div><div class="ttdeci">std::chrono::seconds closeOffset() const</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00082">TimeKeeper.h:82</a></div></div>
<div class="ttc" id="aduration_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a6ea20501ef727ee3f4cd25aa9c164e26"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a6ea20501ef727ee3f4cd25aa9c164e26">ripple::TimeKeeper::closeOffset</a></div><div class="ttdeci">std::chrono::seconds closeOffset() const</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00083">TimeKeeper.h:83</a></div></div>
<div class="ttc" id="acompare_exchange_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange.html">std::atomic::compare_exchange_strong</a></div><div class="ttdeci">T compare_exchange_strong(T... args)</div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_ada2cee023f1dcf3c80250f8840139440"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#ada2cee023f1dcf3c80250f8840139440">ripple::TimeKeeper::closeTime</a></div><div class="ttdeci">time_point closeTime() const</div><div class="ttdoc">Returns the predicted close time, in network time.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00075">TimeKeeper.h:75</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_abfc6614b53f236861e4e61e91574283e"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#abfc6614b53f236861e4e61e91574283e">ripple::TimeKeeper::adjustCloseTime</a></div><div class="ttdeci">std::chrono::seconds adjustCloseTime(std::chrono::seconds by)</div><div class="ttdoc">Adjust the close time, based on the network's view of time.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00089">TimeKeeper.h:89</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_ada2cee023f1dcf3c80250f8840139440"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#ada2cee023f1dcf3c80250f8840139440">ripple::TimeKeeper::closeTime</a></div><div class="ttdeci">time_point closeTime() const</div><div class="ttdoc">Returns the predicted close time, in network time.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00076">TimeKeeper.h:76</a></div></div>
<div class="ttc" id="anamespaceripple_html_ad4e2a948afe60129e9b99dc30af7a5fd"><div class="ttname"><a href="namespaceripple.html#ad4e2a948afe60129e9b99dc30af7a5fd">ripple::epoch_offset</a></div><div class="ttdeci">constexpr static std::chrono::seconds epoch_offset</div><div class="ttdoc">Clock for measuring the network time.</div><div class="ttdef"><b>Definition:</b> <a href="chrono_8h_source.html#l00056">chrono.h:56</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_abfc6614b53f236861e4e61e91574283e"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#abfc6614b53f236861e4e61e91574283e">ripple::TimeKeeper::adjustCloseTime</a></div><div class="ttdeci">std::chrono::seconds adjustCloseTime(std::chrono::seconds by)</div><div class="ttdoc">Adjust the close time, based on the network's view of time.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00090">TimeKeeper.h:90</a></div></div>
<div class="ttc" id="aload_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/atomic/atomic/load.html">std::atomic::load</a></div><div class="ttdeci">T load(T... args)</div></div>
<div class="ttc" id="aatomic_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/atomic.html">atomic</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html"><div class="ttname"><a href="classripple_1_1TimeKeeper.html">ripple::TimeKeeper</a></div><div class="ttdoc">Manages various times used by the server.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00030">TimeKeeper.h:30</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a2a0090c133fcbeb544017a3c7eddab6e"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e">ripple::TimeKeeper::now</a></div><div class="ttdeci">time_point now() const override</div><div class="ttdoc">Returns the current time, using the server's clock.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00063">TimeKeeper.h:63</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html"><div class="ttname"><a href="classripple_1_1TimeKeeper.html">ripple::TimeKeeper</a></div><div class="ttdoc">Manages various times used by the server.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00031">TimeKeeper.h:31</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a2a0090c133fcbeb544017a3c7eddab6e"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a2a0090c133fcbeb544017a3c7eddab6e">ripple::TimeKeeper::now</a></div><div class="ttdeci">time_point now() const override</div><div class="ttdoc">Returns the current time, using the server's clock.</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00064">TimeKeeper.h:64</a></div></div>
<div class="ttc" id="aclassbeast_1_1abstract__clock_html"><div class="ttname"><a href="classbeast_1_1abstract__clock.html">beast::abstract_clock</a></div><div class="ttdoc">Abstract interface to a clock.</div><div class="ttdef"><b>Definition:</b> <a href="abstract__clock_8h_source.html#l00057">abstract_clock.h:57</a></div></div>
<div class="ttc" id="anamespaceripple_html"><div class="ttname"><a href="namespaceripple.html">ripple</a></div><div class="ttdoc">Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.</div><div class="ttdef"><b>Definition:</b> <a href="RCLCensorshipDetector_8h_source.html#l00029">RCLCensorshipDetector.h:29</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_abd0e431f6ed68ad20061bada64314327"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#abd0e431f6ed68ad20061bada64314327">ripple::TimeKeeper::~TimeKeeper</a></div><div class="ttdeci">virtual ~TimeKeeper()=default</div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a0061e7bf92a6d7a7140a57d5eeb2437d"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">ripple::TimeKeeper::closeOffset_</a></div><div class="ttdeci">std::atomic&lt; std::chrono::seconds &gt; closeOffset_</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00033">TimeKeeper.h:33</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a00f890d82fb32b35618b2e0e4244d6e1"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1">ripple::TimeKeeper::adjust</a></div><div class="ttdeci">static constexpr time_point adjust(std::chrono::system_clock::time_point when)</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00037">TimeKeeper.h:37</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a0061e7bf92a6d7a7140a57d5eeb2437d"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a0061e7bf92a6d7a7140a57d5eeb2437d">ripple::TimeKeeper::closeOffset_</a></div><div class="ttdeci">std::atomic&lt; std::chrono::seconds &gt; closeOffset_</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00034">TimeKeeper.h:34</a></div></div>
<div class="ttc" id="aclassripple_1_1TimeKeeper_html_a00f890d82fb32b35618b2e0e4244d6e1"><div class="ttname"><a href="classripple_1_1TimeKeeper.html#a00f890d82fb32b35618b2e0e4244d6e1">ripple::TimeKeeper::adjust</a></div><div class="ttdeci">static constexpr time_point adjust(std::chrono::system_clock::time_point when)</div><div class="ttdef"><b>Definition:</b> <a href="TimeKeeper_8h_source.html#l00038">TimeKeeper.h:38</a></div></div>
<div class="ttc" id="aclassbeast_1_1abstract__clock_html_a4e16832b0bdf9392c5138bbbde024d8e"><div class="ttname"><a href="classbeast_1_1abstract__clock.html#a4e16832b0bdf9392c5138bbbde024d8e">beast::abstract_clock&lt; NetClock &gt;::time_point</a></div><div class="ttdeci">typename NetClock ::time_point time_point</div><div class="ttdef"><b>Definition:</b> <a href="abstract__clock_8h_source.html#l00063">abstract_clock.h:63</a></div></div>
<div class="ttc" id="anow_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/system_clock/now.html">std::chrono::system_clock::now</a></div><div class="ttdeci">T now(T... args)</div></div>
<!-- start footer part -->