event/Loop: move code to HandleDeferred()
This commit is contained in:
parent
7c15e41da5
commit
f685a48008
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user