From da9e5849212337f26d1fa0450ce71cd58aefc30d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 5 Jan 2014 01:50:25 +0100 Subject: event/Loop: combine multiple WakeFD::Write() calls Reduce DeferredMonitor overhead. --- src/event/Loop.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index 40a2469a2..0e76afc25 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -207,11 +207,16 @@ EventLoop::AddDeferred(DeferredMonitor &d) assert(std::find(deferred.begin(), 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; deferred.push_back(&d); mutex.unlock(); - wake_fd.Write(); + if (must_wake) + wake_fd.Write(); } void -- cgit v1.2.3