aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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: