Commit f685a480 authored by Max Kellermann's avatar Max Kellermann

event/Loop: move code to HandleDeferred()

parent 7c15e41d
......@@ -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;
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment