Change Checkpoint API to return total number of checkpoints
Fixes a race condition with SetStateUnsafe that caused some
warnings in the Barrier::~Barrier.
The race was:
RunCheckpoint sees suspended thread, runs the checkpoint. Inside the
checkpoint, the thread state had changed to runnable by
SetStateUnsafe. This occasionally caused more Barrier::Pass than
expected.
The fix is to return the total number of checkpoints instead of just
the runnable ones.
Bug: 24191051
Change-Id: If15a933ed4c8efa66a5f27cd5feaa2e5957ae804
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index c727432..f0933f7 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -91,7 +91,8 @@
Thread* FindThreadByThreadId(uint32_t thin_lock_id);
// Run a checkpoint on threads, running threads are not suspended but run the checkpoint inside
- // of the suspend check. Returns how many checkpoints we should expect to run.
+ // of the suspend check. Returns how many checkpoints that are expected to run, including for
+ // already suspended threads.
size_t RunCheckpoint(Closure* checkpoint_function)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);