event/Loop: combine multiple WakeFD::Write() calls
Reduce DeferredMonitor overhead.
This commit is contained in:
parent
e9d764d7ad
commit
da9e584921
@ -207,11 +207,16 @@ EventLoop::AddDeferred(DeferredMonitor &d)
|
|||||||
assert(std::find(deferred.begin(),
|
assert(std::find(deferred.begin(),
|
||||||
deferred.end(), &d) == deferred.end());
|
deferred.end(), &d) == deferred.end());
|
||||||
|
|
||||||
|
/* we don't need to wake up the EventLoop if another
|
||||||
|
DeferredMonitor has already done it */
|
||||||
|
const bool must_wake = deferred.empty();
|
||||||
|
|
||||||
d.pending = true;
|
d.pending = true;
|
||||||
deferred.push_back(&d);
|
deferred.push_back(&d);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
wake_fd.Write();
|
if (must_wake)
|
||||||
|
wake_fd.Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user