Replace UptimeTimer with UptimeClock

* UptimeClock is a chrono-compatible seconds-precision clock.

* Like UptimeTimer, its purpose is to make it possible for clients
  to query the uptime thousands of times per second without a
  significant performance hit.

* UptimeClock decouples itself from LoadManager by managing its
  own once-per-second update loop.

* Clients now traffic in chrono time_points and durations instead
  of int.
This commit is contained in:
Howard Hinnant
2018-04-23 13:46:37 -04:00
committed by seelabs
parent 717f874767
commit 7d163a45dc
14 changed files with 159 additions and 186 deletions

View File

@@ -36,7 +36,7 @@
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/TaggedCache.h>
#include <ripple/basics/UptimeTimer.h>
#include <ripple/basics/UptimeClock.h>
#include <ripple/core/TimeKeeper.h>
#include <ripple/nodestore/DatabaseShard.h>
#include <ripple/overlay/Overlay.h>
@@ -1792,9 +1792,9 @@ LedgerMaster::makeFetchPack (
std::weak_ptr<Peer> const& wPeer,
std::shared_ptr<protocol::TMGetObjectByHash> const& request,
uint256 haveLedgerHash,
std::uint32_t uUptime)
UptimeClock::time_point uptime)
{
if (UptimeTimer::getInstance ().getElapsedSeconds () > (uUptime + 1))
if (UptimeClock::now() > uptime + 1s)
{
JLOG(m_journal.info()) << "Fetch pack request got stale";
return;
@@ -1916,7 +1916,7 @@ LedgerMaster::makeFetchPack (
wantLedger = getLedgerByHash (haveLedger->info().parentHash);
}
while (wantLedger &&
UptimeTimer::getInstance ().getElapsedSeconds () <= uUptime + 1);
UptimeClock::now() <= uptime + 1s);
JLOG(m_journal.info())
<< "Built fetch pack with " << reply.objects ().size () << " nodes";