diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-27 23:06:34 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-28 01:15:08 +0100 |
commit | b042095ac239be78a704293f217328b7f1b4cc16 (patch) | |
tree | fcf5cc24aa212066562cef91dc24df2c89fd402f /src/zeroconf | |
parent | 3413d1bf23a7ba4f33d015d1ec5024c191fe08e5 (diff) |
event/Loop: use std::chrono
Diffstat (limited to 'src/zeroconf')
-rw-r--r-- | src/zeroconf/AvahiPoll.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/zeroconf/AvahiPoll.cxx b/src/zeroconf/AvahiPoll.cxx index 1cc3d5213..ef6ccef09 100644 --- a/src/zeroconf/AvahiPoll.cxx +++ b/src/zeroconf/AvahiPoll.cxx @@ -78,10 +78,10 @@ protected: } }; -static constexpr unsigned -TimevalToMS(const timeval &tv) +static constexpr std::chrono::steady_clock::duration +TimevalToChrono(const timeval &tv) { - return tv.tv_sec * 1000 + (tv.tv_usec + 500) / 1000; + return std::chrono::seconds(tv.tv_sec) + std::chrono::microseconds(tv.tv_usec); } struct AvahiTimeout final : private TimeoutMonitor { @@ -96,12 +96,12 @@ public: :TimeoutMonitor(_loop), callback(_callback), userdata(_userdata) { if (tv != nullptr) - Schedule(TimevalToMS(*tv)); + Schedule(TimevalToChrono(*tv)); } static void TimeoutUpdate(AvahiTimeout *t, const struct timeval *tv) { if (tv != nullptr) - t->Schedule(TimevalToMS(*tv)); + t->Schedule(TimevalToChrono(*tv)); else t->Cancel(); } |