summaryrefslogtreecommitdiff
path: root/runtime/thread_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/thread_list.h')
-rw-r--r--runtime/thread_list.h29
1 files changed, 13 insertions, 16 deletions
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index a17a11b3ce..29b0c52186 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -70,7 +70,7 @@ class ThreadList {
bool Resume(Thread* thread, SuspendReason reason = SuspendReason::kInternal)
REQUIRES(!Locks::thread_suspend_count_lock_) WARN_UNUSED;
- // Suspends all other threads and gets exclusive access to the mutator lock.
+ // Suspends all threads and gets exclusive access to the mutator lock.
// If long_suspend is true, then other threads who try to suspend will never timeout.
// long_suspend is currenly used for hprof since large heaps take a long time.
void SuspendAll(const char* cause, bool long_suspend = false)
@@ -81,8 +81,10 @@ class ThreadList {
// Suspend a thread using a peer, typically used by the debugger. Returns the thread on success,
// else null. The peer is used to identify the thread to avoid races with the thread terminating.
+ // If the suspension times out then *timeout is set to true.
Thread* SuspendThreadByPeer(jobject peer,
- SuspendReason reason)
+ SuspendReason reason,
+ bool* timed_out)
REQUIRES(!Locks::mutator_lock_,
!Locks::thread_list_lock_,
!Locks::thread_suspend_count_lock_);
@@ -90,8 +92,8 @@ class ThreadList {
// Suspend a thread using its thread id, typically used by lock/monitor inflation. Returns the
// thread on success else null. The thread id is used to identify the thread to avoid races with
// the thread terminating. Note that as thread ids are recycled this may not suspend the expected
- // thread, that may be terminating.
- Thread* SuspendThreadByThreadId(uint32_t thread_id, SuspendReason reason)
+ // thread, that may be terminating. If the suspension times out then *timeout is set to true.
+ Thread* SuspendThreadByThreadId(uint32_t thread_id, SuspendReason reason, bool* timed_out)
REQUIRES(!Locks::mutator_lock_,
!Locks::thread_list_lock_,
!Locks::thread_suspend_count_lock_);
@@ -111,9 +113,8 @@ class ThreadList {
// Running threads are not suspended but run the checkpoint inside of the suspend check. The
// return value includes already suspended threads for b/24191051. Runs or requests the
// callback, if non-null, inside the thread_list_lock critical section after determining the
- // runnable/suspended states of the threads. Does not wait for completion of the checkpoint
- // function in running threads. If the caller holds the mutator lock, then all instances of the
- // checkpoint function are run with the mutator lock.
+ // runnable/suspended states of the threads. Does not wait for completion of the callbacks in
+ // running threads.
size_t RunCheckpoint(Closure* checkpoint_function, Closure* callback = nullptr)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
@@ -196,15 +197,12 @@ class ThreadList {
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
void SuspendAllInternal(Thread* self,
+ Thread* ignore1,
+ Thread* ignore2 = nullptr,
SuspendReason reason = SuspendReason::kInternal)
- REQUIRES(!Locks::thread_list_lock_,
- !Locks::thread_suspend_count_lock_,
- !Locks::mutator_lock_);
-
- // Wait for suspend barrier to reach zero. Return false on timeout.
- bool WaitForSuspendBarrier(AtomicInteger* barrier);
+ REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
- void AssertOtherThreadsAreSuspended(Thread* self)
+ void AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread* ignore2 = nullptr)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
std::bitset<kMaxThreadId> allocated_ids_ GUARDED_BY(Locks::allocated_thread_ids_lock_);
@@ -213,7 +211,6 @@ class ThreadList {
std::list<Thread*> list_ GUARDED_BY(Locks::thread_list_lock_);
// Ongoing suspend all requests, used to ensure threads added to list_ respect SuspendAll.
- // The value is always either 0 or 1.
int suspend_all_count_ GUARDED_BY(Locks::thread_suspend_count_lock_);
// Number of threads unregistering, ~ThreadList blocks until this hits 0.
@@ -221,7 +218,7 @@ class ThreadList {
// Thread suspend time histogram. Only modified when all the threads are suspended, so guarding
// by mutator lock ensures no thread can read when another thread is modifying it.
- Histogram<uint64_t> suspend_all_histogram_ GUARDED_BY(Locks::mutator_lock_);
+ Histogram<uint64_t> suspend_all_historam_ GUARDED_BY(Locks::mutator_lock_);
// Whether or not the current thread suspension is long.
bool long_suspend_;