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);
|
deferred.erase(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
EventLoop::OnSocketReady(gcc_unused unsigned flags)
|
EventLoop::HandleDeferred()
|
||||||
{
|
{
|
||||||
assert(!quit);
|
|
||||||
|
|
||||||
wake_fd.Read();
|
|
||||||
|
|
||||||
mutex.lock();
|
|
||||||
|
|
||||||
while (!deferred.empty() && !quit) {
|
while (!deferred.empty() && !quit) {
|
||||||
DeferredMonitor &m = *deferred.front();
|
DeferredMonitor &m = *deferred.front();
|
||||||
assert(m.pending);
|
assert(m.pending);
|
||||||
@ -237,7 +231,17 @@ EventLoop::OnSocketReady(gcc_unused unsigned flags)
|
|||||||
m.RunDeferred();
|
m.RunDeferred();
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
EventLoop::OnSocketReady(gcc_unused unsigned flags)
|
||||||
|
{
|
||||||
|
assert(!quit);
|
||||||
|
|
||||||
|
wake_fd.Read();
|
||||||
|
|
||||||
|
mutex.lock();
|
||||||
|
HandleDeferred();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -157,6 +157,13 @@ public:
|
|||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Invoke all pending DeferredMonitors.
|
||||||
|
*
|
||||||
|
* Caller must lock the mutex.
|
||||||
|
*/
|
||||||
|
void HandleDeferred();
|
||||||
|
|
||||||
virtual bool OnSocketReady(unsigned flags) override;
|
virtual bool OnSocketReady(unsigned flags) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user