| OLD | NEW |
| 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 #include <pthread.h> | 8 #include <pthread.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 for (const auto& result : results) { | 338 for (const auto& result : results) { |
| 339 auto id = result.cookie; | 339 auto id = result.cookie; |
| 340 auto it = handlers_.find(id); | 340 auto it = handlers_.find(id); |
| 341 // Though we should find an entry for the first result, a handler that we | 341 // Though we should find an entry for the first result, a handler that we |
| 342 // invoke may remove other handlers. | 342 // invoke may remove other handlers. |
| 343 if (it == handlers_.end()) | 343 if (it == handlers_.end()) |
| 344 continue; | 344 continue; |
| 345 | 345 |
| 346 auto handler = it->second.handler; | 346 auto handler = it->second.handler; |
| 347 handlers_.erase(it); | 347 handlers_.erase(it); |
| 348 MojoResult r = WaitSetRemove(wait_set_.get(), id); |
| 349 MOJO_ALLOW_UNUSED_LOCAL(r); |
| 350 assert(r == MOJO_RESULT_OK); |
| 348 if (result.wait_result == MOJO_RESULT_OK) | 351 if (result.wait_result == MOJO_RESULT_OK) |
| 349 handler->OnHandleReady(id); | 352 handler->OnHandleReady(id); |
| 350 else | 353 else |
| 351 handler->OnHandleError(id, result.wait_result); | 354 handler->OnHandleError(id, result.wait_result); |
| 352 did_work = true; | 355 did_work = true; |
| 353 | 356 |
| 354 if (current_run_state_->should_quit) | 357 if (current_run_state_->should_quit) |
| 355 break; | 358 break; |
| 356 } | 359 } |
| 357 return did_work; | 360 return did_work; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 384 handler->OnHandleError(id, MOJO_RESULT_DEADLINE_EXCEEDED); | 387 handler->OnHandleError(id, MOJO_RESULT_DEADLINE_EXCEEDED); |
| 385 did_work = true; | 388 did_work = true; |
| 386 | 389 |
| 387 if (current_run_state_->should_quit) | 390 if (current_run_state_->should_quit) |
| 388 break; | 391 break; |
| 389 } | 392 } |
| 390 return did_work; | 393 return did_work; |
| 391 } | 394 } |
| 392 | 395 |
| 393 } // namespace mojo | 396 } // namespace mojo |
| OLD | NEW |