diff options
author | Max Kellermann <max@duempel.org> | 2014-01-05 01:50:25 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-05 02:15:10 +0100 |
commit | da9e5849212337f26d1fa0450ce71cd58aefc30d (patch) | |
tree | b7ccab1b72a782182c3fe4763f74faf86ad38161 /src/event | |
parent | e9d764d7ad8f912c110cfe73f0aaef7382b1a569 (diff) | |
download | mpd-da9e5849212337f26d1fa0450ce71cd58aefc30d.tar.gz mpd-da9e5849212337f26d1fa0450ce71cd58aefc30d.tar.xz mpd-da9e5849212337f26d1fa0450ce71cd58aefc30d.zip |
event/Loop: combine multiple WakeFD::Write() calls
Reduce DeferredMonitor overhead.
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/Loop.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
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 |