summaryrefslogtreecommitdiff
path: root/runtime/gc/reference_queue.h
diff options
context:
space:
mode:
author Richard Uhler <ruhler@google.com> 2016-01-15 14:08:05 -0800
committer Richard Uhler <ruhler@google.com> 2016-01-28 15:34:19 -0800
commitc4695dfdab80c280c98a89c20e027a3804191585 (patch)
treeb78f388ac75edd9f02abfcae68aad7d445af75d1 /runtime/gc/reference_queue.h
parent97f4bc04b61d5cf78b0820dbf18e999b20d7a108 (diff)
Always use pendingNext to test enqueability of references.
Also clean up a misleading comment in a reference queue test. Bug: 24404957 Change-Id: Ieea4788039ecef73cba1871fb480a439bf65b499
Diffstat (limited to 'runtime/gc/reference_queue.h')
-rw-r--r--runtime/gc/reference_queue.h21
1 files changed, 9 insertions, 12 deletions
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