diff options
author | 2014-04-24 16:14:43 -0700 | |
---|---|---|
committer | 2014-04-24 16:16:23 -0700 | |
commit | 92b7889dfbfb44e875ba46c4e9ec3235c37b7709 (patch) | |
tree | c95e28ad4b90d731fcffe159bf9f46d35772b7ad /runtime/scoped_thread_state_change.h | |
parent | 17c50db442d2791d9c4d7d1e98060556c323ce9b (diff) |
Clean up ScopedThreadStateChange + Get/SetPrimtiveArrayRegion
Simplified code in ScopedThreadStateChange and fixed an incorrect
name in Get/SetPrimitiveArrayRegion.
Change-Id: Id71affec1d64911449d792911cd52104dd179840
Diffstat (limited to 'runtime/scoped_thread_state_change.h')
-rw-r--r-- | runtime/scoped_thread_state_change.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h index 404c61640d..7698d6a49b 100644 --- a/runtime/scoped_thread_state_change.h +++ b/runtime/scoped_thread_state_change.h @@ -38,23 +38,18 @@ class ScopedThreadStateChange { Runtime* runtime = Runtime::Current(); CHECK(runtime == NULL || !runtime->IsStarted() || runtime->IsShuttingDown(self_)); } else { - bool runnable_transition; DCHECK_EQ(self, Thread::Current()); // Read state without locks, ok as state is effectively thread local and we're not interested // in the suspend count (this will be handled in the runnable transitions). old_thread_state_ = self->GetState(); - runnable_transition = old_thread_state_ == kRunnable || new_thread_state == kRunnable; - if (!runnable_transition) { - // A suspended transition to another effectively suspended transition, ok to use Unsafe. - self_->SetState(new_thread_state); - } - - if (runnable_transition && old_thread_state_ != new_thread_state) { + if (old_thread_state_ != new_thread_state) { if (new_thread_state == kRunnable) { self_->TransitionFromSuspendedToRunnable(); - } else { - DCHECK_EQ(old_thread_state_, kRunnable); + } else if (old_thread_state_ == kRunnable) { self_->TransitionFromRunnableToSuspended(new_thread_state); + } else { + // A suspended transition to another effectively suspended transition, ok to use Unsafe. + self_->SetState(new_thread_state); } } } |