aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-05 01:32:59 +0100
committerMax Kellermann <max@duempel.org>2014-01-05 01:35:12 +0100
commitf685a4800899cd3f7812b303a2e12700bdc445e2 (patch)
treef1177ce6002c2334c63ae4fddaaf7a668623f1ea
parent7c15e41da56243f364c32229108c5350d9b48788 (diff)
downloadmpd-f685a4800899cd3f7812b303a2e12700bdc445e2.tar.gz
mpd-f685a4800899cd3f7812b303a2e12700bdc445e2.tar.xz
mpd-f685a4800899cd3f7812b303a2e12700bdc445e2.zip
event/Loop: move code to HandleDeferred()
-rw-r--r--src/event/Loop.cxx20
-rw-r--r--src/event/Loop.hxx7
2 files changed, 19 insertions, 8 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index 57c966bb7..8c8ac9993 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -217,15 +217,9 @@ EventLoop::RemoveDeferred(DeferredMonitor &d)
deferred.erase(i);
}
-bool
-EventLoop::OnSocketReady(gcc_unused unsigned flags)
+void
+EventLoop::HandleDeferred()
{
- assert(!quit);
-
- wake_fd.Read();
-
- mutex.lock();
-
while (!deferred.empty() && !quit) {
DeferredMonitor &m = *deferred.front();
assert(m.pending);
@@ -237,7 +231,17 @@ EventLoop::OnSocketReady(gcc_unused unsigned flags)
m.RunDeferred();
mutex.lock();
}
+}
+bool
+EventLoop::OnSocketReady(gcc_unused unsigned flags)
+{
+ assert(!quit);
+
+ wake_fd.Read();
+
+ mutex.lock();
+ HandleDeferred();
mutex.unlock();
return true;
diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx
index 5ac7d635f..b8d090eb5 100644
--- a/src/event/Loop.hxx
+++ b/src/event/Loop.hxx
@@ -157,6 +157,13 @@ public:
void Run();
private:
+ /**
+ * Invoke all pending DeferredMonitors.
+ *
+ * Caller must lock the mutex.
+ */
+ void HandleDeferred();
+
virtual bool OnSocketReady(unsigned flags) override;
public: