aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-05 01:38:51 +0100
committerMax Kellermann <max@duempel.org>2014-01-05 02:15:01 +0100
commite9d764d7ad8f912c110cfe73f0aaef7382b1a569 (patch)
tree50187cc70fbffddf5669bc8b77f654302a3122af
parent626895577840f25c1b0b1f3208310a82c4202d58 (diff)
downloadmpd-e9d764d7ad8f912c110cfe73f0aaef7382b1a569.tar.gz
mpd-e9d764d7ad8f912c110cfe73f0aaef7382b1a569.tar.xz
mpd-e9d764d7ad8f912c110cfe73f0aaef7382b1a569.zip
event/Loop: add attribute "again"
Improved support for added events.
-rw-r--r--src/event/Loop.cxx6
-rw-r--r--src/event/Loop.hxx6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index e32ba5582..40a2469a2 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -79,6 +79,7 @@ EventLoop::AddIdle(IdleMonitor &i)
assert(std::find(idle.begin(), idle.end(), &i) == idle.end());
idle.push_back(&i);
+ again = true;
}
void
@@ -98,6 +99,7 @@ EventLoop::AddTimer(TimeoutMonitor &t, unsigned ms)
assert(IsInside());
timers.insert(TimerRecord(t, now_ms + ms));
+ again = true;
}
void
@@ -123,6 +125,7 @@ EventLoop::Run()
do {
now_ms = ::MonotonicClockMS();
+ again = false;
/* invoke timers */
@@ -149,7 +152,6 @@ EventLoop::Run()
/* invoke idle */
- const bool idle_empty = idle.empty();
while (!idle.empty()) {
IdleMonitor &m = *idle.front();
idle.pop_front();
@@ -159,7 +161,7 @@ EventLoop::Run()
return;
}
- if (!idle_empty)
+ if (again)
/* re-evaluate timers because one of the
IdleMonitors may have added a new
timeout */
diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx
index e8c737e1e..bfa8dc4a9 100644
--- a/src/event/Loop.hxx
+++ b/src/event/Loop.hxx
@@ -84,6 +84,12 @@ class EventLoop final : SocketMonitor
bool quit;
+ /**
+ * True when the object has been modified and another check is
+ * necessary before going to sleep via PollGroup::ReadEvents().
+ */
+ bool again;
+
PollGroup poll_group;
PollResult poll_result;