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

Side by Side Diff: mojo/public/cpp/utility/lib/run_loop.cc

Issue 733563002: Mojo Example that demos the difference between providing and requesting an interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Manage IntegerServicePtr and DemoTask lifetimes. Fixed RunLoop::RemoveFirstInvalidHandle() Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "mojo/public/cpp/utility/run_loop.h" 5 #include "mojo/public/cpp/utility/run_loop.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (result == MOJO_RESULT_INVALID_ARGUMENT || 212 if (result == MOJO_RESULT_INVALID_ARGUMENT ||
213 result == MOJO_RESULT_FAILED_PRECONDITION) { 213 result == MOJO_RESULT_FAILED_PRECONDITION) {
214 // Remove the handle first, this way if OnHandleError() tries to remove 214 // Remove the handle first, this way if OnHandleError() tries to remove
215 // the handle our iterator isn't invalidated. 215 // the handle our iterator isn't invalidated.
216 assert(handler_data_.find(wait_state.handles[i]) != handler_data_.end()); 216 assert(handler_data_.find(wait_state.handles[i]) != handler_data_.end());
217 RunLoopHandler* handler = handler_data_[wait_state.handles[i]].handler; 217 RunLoopHandler* handler = handler_data_[wait_state.handles[i]].handler;
218 handler_data_.erase(wait_state.handles[i]); 218 handler_data_.erase(wait_state.handles[i]);
219 handler->OnHandleError(wait_state.handles[i], result); 219 handler->OnHandleError(wait_state.handles[i], result);
220 return true; 220 return true;
221 } 221 }
222 assert(MOJO_RESULT_DEADLINE_EXCEEDED == result); 222 assert(MOJO_RESULT_DEADLINE_EXCEEDED == result || MOJO_RESULT_OK == result);
223 } 223 }
224 return false; 224 return false;
225 } 225 }
226 226
227 RunLoop::WaitState RunLoop::GetWaitState(bool non_blocking) const { 227 RunLoop::WaitState RunLoop::GetWaitState(bool non_blocking) const {
228 WaitState wait_state; 228 WaitState wait_state;
229 MojoTimeTicks min_time = kInvalidTimeTicks; 229 MojoTimeTicks min_time = kInvalidTimeTicks;
230 for (HandleToHandlerData::const_iterator i = handler_data_.begin(); 230 for (HandleToHandlerData::const_iterator i = handler_data_.begin();
231 i != handler_data_.end(); 231 i != handler_data_.end();
232 ++i) { 232 ++i) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // std::priority_queue<> puts the least element at the end of the queue. We 270 // std::priority_queue<> puts the least element at the end of the queue. We
271 // want the soonest eligible task to be at the head of the queue, so 271 // want the soonest eligible task to be at the head of the queue, so
272 // run_times further in the future are considered lesser. 272 // run_times further in the future are considered lesser.
273 return run_time > other.run_time; 273 return run_time > other.run_time;
274 } 274 }
275 275
276 return sequence_number > other.sequence_number; 276 return sequence_number > other.sequence_number;
277 } 277 }
278 278
279 } // namespace mojo 279 } // namespace mojo
OLDNEW
« examples/indirect_service/integer_service.cc ('K') | « examples/indirect_service/integer_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698