Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Unified Diff: mojo/message_pump/message_pump_mojo.h

Issue 1448233002: Avoid iterating over all handles in MessagePumpMojo on every iteration to calculate deadlines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo.cc » ('j') | mojo/message_pump/message_pump_mojo.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/message_pump/message_pump_mojo.h
diff --git a/mojo/message_pump/message_pump_mojo.h b/mojo/message_pump/message_pump_mojo.h
index 06869730eec7a0e1fa83622b3639432e905a744e..50c7812a0d6385c79019dbf07486e000228cb3a2 100644
--- a/mojo/message_pump/message_pump_mojo.h
+++ b/mojo/message_pump/message_pump_mojo.h
@@ -6,6 +6,7 @@
#define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
#include <map>
+#include <set>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -117,6 +118,10 @@ class MOJO_MESSAGE_PUMP_EXPORT MessagePumpMojo : public base::MessagePump {
base::Lock run_state_lock_;
HandleToHandler handlers_;
+ // Set of handles that have a deadline set. Avoids iterating over all elements
+ // in |handles_| in the common case (no deadline set).
+ // TODO(amistry): Make this better and avoid special-casing deadlines.
+ std::set<Handle> deadline_handles_;
sky 2015/11/17 18:35:11 If we're really worried about efficiency, why don'
Anand Mistry (off Chromium) 2015/11/17 23:54:39 Sorting by TimeTicks would make removing by handle
sky 2015/11/17 23:58:42 If no one specifies a deadline, then wouldn't a bo
Anand Mistry (off Chromium) 2015/11/18 00:10:12 It would, but then if one user does come along and
// An ever increasing value assigned to each Handler::id. Used to detect
// uniqueness while notifying. That is, while notifying expired timers we copy
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo.cc » ('j') | mojo/message_pump/message_pump_mojo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698