Use libuv's cached current time for `time_now()`

We are calling time_now() a huge amount, and it is a major consumer of
CPU cycles, but we don't need it: most of the time the current event
loop time is enough.
pull/1797/head
Jason Rhinelander 3 years ago
parent b2ee003329
commit 5115162066

@ -75,11 +75,11 @@ namespace llarp
virtual bool
running() const = 0;
// Returns a current steady clock time value representing the current time with event loop tick
// granularity. That is, the value is typically only updated at the beginning of an event loop
// tick.
virtual llarp_time_t
time_now() const
{
return llarp::time_now_ms();
}
time_now() const = 0;
// Calls a function/lambda/etc. If invoked from within the event loop itself this calls the
// given lambda immediately; otherwise it passes it to `call_soon()` to be queued to run at the

@ -31,6 +31,12 @@ namespace llarp::uv
bool
running() const override;
llarp_time_t
time_now() const override
{
return m_Impl->now();
}
void
call_later(llarp_time_t delay_ms, std::function<void(void)> callback) override;

Loading…
Cancel
Save