Add and use ScopedSuspendAll
Usage replaces most SuspendAll and ResumeAll calls.
Change-Id: I355683a5365876242cea85a656dcb58455f7a294
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index e2094dc..dfc1f5f 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -1403,10 +1403,11 @@
// comment in Heap::VisitObjects().
heap->IncrementDisableMovingGC(self);
}
- Runtime::Current()->GetThreadList()->SuspendAll(__FUNCTION__, true /* long suspend */);
- Hprof hprof(filename, fd, direct_to_ddms);
- hprof.Dump();
- Runtime::Current()->GetThreadList()->ResumeAll();
+ {
+ ScopedSuspendAll ssa(__FUNCTION__, true /* long suspend */);
+ Hprof hprof(filename, fd, direct_to_ddms);
+ hprof.Dump();
+ }
if (heap->IsGcConcurrentAndMoving()) {
heap->DecrementDisableMovingGC(self);
}