Chromium Code Reviews| Index: mojo/edk/system/waiter.cc |
| diff --git a/mojo/edk/system/waiter.cc b/mojo/edk/system/waiter.cc |
| index 1ede9d071b7b6c2166b34e16f7f0ecca1c8bc44b..e254b5ca2be5b2b1febca388811ce658e72cbaa1 100644 |
| --- a/mojo/edk/system/waiter.cc |
| +++ b/mojo/edk/system/waiter.cc |
| @@ -19,7 +19,7 @@ Waiter::Waiter() |
| initialized_(false), |
| #endif |
| awoken_(false), |
| - awake_result_(MOJO_RESULT_INTERNAL), |
| + awake_reason_(AwakeReason::CANCELLED), |
| awake_context_(static_cast<uint64_t>(-1)) { |
| } |
| @@ -30,13 +30,12 @@ void Waiter::Init() { |
| initialized_ = true; |
| #endif |
| awoken_ = false; |
| - // NOTE(vtl): If performance ever becomes an issue, we can disable the setting |
| - // of |awake_result_| (except the first one in |Awake()|) in Release builds. |
|
vardhan
2016/06/21 07:49:01
weird
|
| - awake_result_ = MOJO_RESULT_INTERNAL; |
| } |
| // TODO(vtl): Fast-path the |deadline == 0| case? |
| -MojoResult Waiter::Wait(MojoDeadline deadline, uint64_t* context) { |
| +MojoResult Waiter::Wait(MojoDeadline deadline, |
| + uint64_t* context, |
| + HandleSignalsState* signals_state) { |
| MutexLocker locker(&mutex_); |
| #ifndef NDEBUG |
| @@ -47,10 +46,11 @@ MojoResult Waiter::Wait(MojoDeadline deadline, uint64_t* context) { |
| // Fast-path the already-awoken case: |
| if (awoken_) { |
| - DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL); |
| if (context) |
| *context = awake_context_; |
| - return awake_result_; |
| + if (signals_state) |
| + *signals_state = signals_state_; |
| + return MojoResultForAwakeReason(awake_reason_); |
| } |
| if (deadline == MOJO_DEADLINE_INDEFINITE) { |
| @@ -85,10 +85,11 @@ MojoResult Waiter::Wait(MojoDeadline deadline, uint64_t* context) { |
| } |
| } |
| - DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL); |
| if (context) |
| *context = awake_context_; |
| - return awake_result_; |
| + if (signals_state) |
| + *signals_state = signals_state_; |
| + return MojoResultForAwakeReason(awake_reason_); |
| } |
| bool Waiter::Awake(uint64_t context, |
| @@ -100,7 +101,8 @@ bool Waiter::Awake(uint64_t context, |
| return true; |
| awoken_ = true; |
| - awake_result_ = MojoResultForAwakeReason(reason); |
| + awake_reason_ = reason; |
| + signals_state_ = signals_state; |
| awake_context_ = context; |
| cv_.Signal(); |
| // |cv_.Wait()|/|cv_.WaitWithTimeout()| will return after |mutex_| is |