| OLD | NEW |
| 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 #include "mojo/edk/system/waiter.h" | 5 #include "mojo/edk/system/waiter.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/edk/platform/time_ticks.h" | 8 #include "mojo/edk/platform/time_ticks.h" |
| 9 | 9 |
| 10 using mojo::platform::GetTimeTicks; | 10 using mojo::platform::GetTimeTicks; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 wait_remaining = deadline - elapsed; | 84 wait_remaining = deadline - elapsed; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL); | 88 DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL); |
| 89 if (context) | 89 if (context) |
| 90 *context = awake_context_; | 90 *context = awake_context_; |
| 91 return awake_result_; | 91 return awake_result_; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool Waiter::Awake(MojoResult result, uint64_t context) { | 94 bool Waiter::Awake(uint64_t context, |
| 95 AwakeReason reason, |
| 96 const HandleSignalsState& signals_state) { |
| 95 MutexLocker locker(&mutex_); | 97 MutexLocker locker(&mutex_); |
| 96 | 98 |
| 97 if (awoken_) | 99 if (awoken_) |
| 98 return true; | 100 return true; |
| 99 | 101 |
| 100 awoken_ = true; | 102 awoken_ = true; |
| 101 awake_result_ = result; | 103 awake_result_ = MojoResultForAwakeReason(reason); |
| 102 awake_context_ = context; | 104 awake_context_ = context; |
| 103 cv_.Signal(); | 105 cv_.Signal(); |
| 104 // |cv_.Wait()|/|cv_.WaitWithTimeout()| will return after |mutex_| is | 106 // |cv_.Wait()|/|cv_.WaitWithTimeout()| will return after |mutex_| is |
| 105 // released. | 107 // released. |
| 106 return true; | 108 return true; |
| 107 } | 109 } |
| 108 | 110 |
| 109 } // namespace system | 111 } // namespace system |
| 110 } // namespace mojo | 112 } // namespace mojo |
| OLD | NEW |