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

Side by Side 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: Review comments. 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_ 5 #ifndef MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
6 #define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_ 6 #define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_pump.h" 13 #include "base/message_loop/message_pump.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "mojo/message_pump/mojo_message_pump_export.h" 17 #include "mojo/message_pump/mojo_message_pump_export.h"
17 #include "mojo/public/cpp/system/core.h" 18 #include "mojo/public/cpp/system/core.h"
18 19
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // If non-NULL we're running (inside Run()). Member is reference to value on 111 // If non-NULL we're running (inside Run()). Member is reference to value on
111 // stack. 112 // stack.
112 RunState* run_state_; 113 RunState* run_state_;
113 114
114 // Lock for accessing |run_state_|. In general the only method that we have to 115 // Lock for accessing |run_state_|. In general the only method that we have to
115 // worry about is ScheduleWork(). All other methods are invoked on the same 116 // worry about is ScheduleWork(). All other methods are invoked on the same
116 // thread. 117 // thread.
117 base::Lock run_state_lock_; 118 base::Lock run_state_lock_;
118 119
119 HandleToHandler handlers_; 120 HandleToHandler handlers_;
121 // Set of handles that have a deadline set. Avoids iterating over all elements
122 // in |handles_| in the common case (no deadline set).
123 // TODO(amistry): Make this better and avoid special-casing deadlines.
124 std::set<Handle> deadline_handles_;
120 125
121 // An ever increasing value assigned to each Handler::id. Used to detect 126 // An ever increasing value assigned to each Handler::id. Used to detect
122 // uniqueness while notifying. That is, while notifying expired timers we copy 127 // uniqueness while notifying. That is, while notifying expired timers we copy
123 // |handlers_| and only notify handlers whose id match. If the id does not 128 // |handlers_| and only notify handlers whose id match. If the id does not
124 // match it means the handler was removed then added so that we shouldn't 129 // match it means the handler was removed then added so that we shouldn't
125 // notify it. 130 // notify it.
126 int next_handler_id_; 131 int next_handler_id_;
127 132
128 base::ObserverList<Observer> observers_; 133 base::ObserverList<Observer> observers_;
129 134
130 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo); 135 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo);
131 }; 136 };
132 137
133 } // namespace common 138 } // namespace common
134 } // namespace mojo 139 } // namespace mojo
135 140
136 #endif // MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_ 141 #endif // MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698