summaryrefslogtreecommitdiff
path: root/src/event/Loop.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-08-29 13:34:08 +0200
committerMax Kellermann <max@musicpd.org>2017-08-29 14:13:09 +0200
commit71ed3ff992f2118e4d7ffe90cf186a071b129858 (patch)
treedb1cd3b73212dce62aeac3f57df46a0a847b7618 /src/event/Loop.cxx
parentd4266d0063e9205f7d6a54fc2b4659b838572ad4 (diff)
event/Loop: move TimerRecord::due to class TimeoutMonitor
Prepare to eliminate the TimerRecord struct.
Diffstat (limited to 'src/event/Loop.cxx')
-rw-r--r--src/event/Loop.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index 8e2098851..5a9be77e7 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -27,6 +27,18 @@
#include <algorithm>
+inline std::chrono::steady_clock::time_point
+EventLoop::TimerRecord::GetDue() const noexcept
+{
+ return timer.due;
+}
+
+inline bool
+EventLoop::TimerRecord::operator<(const TimerRecord &other) const noexcept
+{
+ return timer.due < other.timer.due;
+}
+
EventLoop::EventLoop(ThreadId _thread)
:SocketMonitor(*this), thread(_thread)
{
@@ -93,7 +105,8 @@ EventLoop::AddTimer(TimeoutMonitor &t, std::chrono::steady_clock::duration d)
{
assert(IsInside());
- timers.insert(TimerRecord(t, now + d));
+ t.due = now + d;
+ timers.insert(TimerRecord(t));
again = true;
}
@@ -150,7 +163,7 @@ EventLoop::Run()
break;
}
- timeout = i->due - now;
+ timeout = i->GetDue() - now;
if (timeout > timeout.zero())
break;