From c4695dfdab80c280c98a89c20e027a3804191585 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Fri, 15 Jan 2016 14:08:05 -0800 Subject: Always use pendingNext to test enqueability of references. Also clean up a misleading comment in a reference queue test. Bug: 24404957 Change-Id: Ieea4788039ecef73cba1871fb480a439bf65b499 --- runtime/gc/reference_queue.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'runtime/gc/reference_queue.h') diff --git a/runtime/gc/reference_queue.h b/runtime/gc/reference_queue.h index aabac97742..04d3454c04 100644 --- a/runtime/gc/reference_queue.h +++ b/runtime/gc/reference_queue.h @@ -44,27 +44,24 @@ class GarbageCollector; class Heap; // Used to temporarily store java.lang.ref.Reference(s) during GC and prior to queueing on the -// appropriate java.lang.ref.ReferenceQueue. The linked list is maintained in the -// java.lang.ref.Reference objects. +// appropriate java.lang.ref.ReferenceQueue. The linked list is maintained as an unordered, +// circular, and singly-linked list using the pendingNext fields of the java.lang.ref.Reference +// objects. class ReferenceQueue { public: explicit ReferenceQueue(Mutex* lock); - // Enqueue a reference if is not already enqueued. Thread safe to call from multiple threads - // since it uses a lock to avoid a race between checking for the references presence and adding - // it. + // Enqueue a reference if it is unprocessed. Thread safe to call from multiple + // threads since it uses a lock to avoid a race between checking for the references presence and + // adding it. void AtomicEnqueueIfNotEnqueued(Thread* self, mirror::Reference* ref) SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!*lock_); - // Enqueue a reference, unlike EnqueuePendingReference, enqueue reference checks that the - // reference IsEnqueueable. Not thread safe, used when mutators are paused to minimize lock - // overhead. + // Enqueue a reference. The reference must be unprocessed. + // Not thread safe, used when mutators are paused to minimize lock overhead. void EnqueueReference(mirror::Reference* ref) SHARED_REQUIRES(Locks::mutator_lock_); - // Enqueue a reference without checking that it is enqueable. - void EnqueuePendingReference(mirror::Reference* ref) SHARED_REQUIRES(Locks::mutator_lock_); - - // Dequeue the first reference (returns list_). + // Dequeue a reference from the queue and return that dequeued reference. mirror::Reference* DequeuePendingReference() SHARED_REQUIRES(Locks::mutator_lock_); // Enqueues finalizer references with white referents. White referents are blackened, moved to -- cgit v1.2.3-59-g8ed1b