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

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

Issue 1825553002: Properly "handle" MOJO_RESULT_BUSY in a few flaces. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months 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 | « mojo/public/cpp/system/wait.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 Handle handle = wait_state.handles[wmr.index]; 163 Handle handle = wait_state.handles[wmr.index];
164 assert(handler_data_.find(handle) != handler_data_.end()); 164 assert(handler_data_.find(handle) != handler_data_.end());
165 RunLoopHandler* handler = handler_data_[handle].handler; 165 RunLoopHandler* handler = handler_data_[handle].handler;
166 166
167 switch (wmr.result) { 167 switch (wmr.result) {
168 case MOJO_RESULT_OK: 168 case MOJO_RESULT_OK:
169 handler->OnHandleReady(handle); 169 handler->OnHandleReady(handle);
170 return true; 170 return true;
171 case MOJO_RESULT_INVALID_ARGUMENT: 171 case MOJO_RESULT_INVALID_ARGUMENT:
172 case MOJO_RESULT_CANCELLED:
173 case MOJO_RESULT_BUSY:
174 // These results indicate a bug in "our" code (e.g., race conditions).
175 assert(false);
176 // Fall through.
172 case MOJO_RESULT_FAILED_PRECONDITION: 177 case MOJO_RESULT_FAILED_PRECONDITION:
173 // Remove the handle first, this way if OnHandleError() tries to remove 178 // Remove the handle first, this way if OnHandleError() tries to remove
174 // the handle our iterator isn't invalidated. 179 // the handle our iterator isn't invalidated.
175 handler_data_.erase(handle); 180 handler_data_.erase(handle);
176 handler->OnHandleError(handle, wmr.result); 181 handler->OnHandleError(handle, wmr.result);
177 return true; 182 return true;
178 default: 183 default:
179 assert(false); 184 assert(false);
180 return false; 185 return false;
181 } 186 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // std::priority_queue<> puts the least element at the end of the queue. We 266 // std::priority_queue<> puts the least element at the end of the queue. We
262 // want the soonest eligible task to be at the head of the queue, so 267 // want the soonest eligible task to be at the head of the queue, so
263 // run_times further in the future are considered lesser. 268 // run_times further in the future are considered lesser.
264 return run_time > other.run_time; 269 return run_time > other.run_time;
265 } 270 }
266 271
267 return sequence_number > other.sequence_number; 272 return sequence_number > other.sequence_number;
268 } 273 }
269 274
270 } // namespace mojo 275 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/wait.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698