Add and use ScopedSuspendAll
Usage replaces most SuspendAll and ResumeAll calls.
Change-Id: I355683a5365876242cea85a656dcb58455f7a294
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index 7ddc7cc..089f453 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -421,12 +421,11 @@
if (heap_bitmap_exclusive_locked) {
Locks::heap_bitmap_lock_->ExclusiveUnlock(self);
}
- Locks::mutator_lock_->SharedUnlock(self);
- ThreadList* tl = Runtime::Current()->GetThreadList();
- tl->SuspendAll(__FUNCTION__);
- mark_sweep_->VerifyRoots();
- tl->ResumeAll();
- Locks::mutator_lock_->SharedLock(self);
+ {
+ ScopedThreadSuspension(self, kSuspended);
+ ScopedSuspendAll ssa(__FUNCTION__);
+ mark_sweep_->VerifyRoots();
+ }
if (heap_bitmap_exclusive_locked) {
Locks::heap_bitmap_lock_->ExclusiveLock(self);
}