diff options
author | 2014-12-11 18:43:48 -0800 | |
---|---|---|
committer | 2014-12-12 12:08:16 -0800 | |
commit | 9e2094f921b63582e84d65849b1c5c6dc4d22b44 (patch) | |
tree | 02613d533bdc382988b7fc70954c15c2ea4575aa /runtime/gc/reference_queue.cc | |
parent | 6b1497421c7c81cb9bf2ce077f1ef3d8ac24cfcb (diff) |
Add ReferenceQueue test
Also cleaned up reference queue.
TODO: Add tests for missing functionality.
Bug: 10808403
Change-Id: I182f9cb69022fe542ea9e53d4c6d35cff90af332
Diffstat (limited to 'runtime/gc/reference_queue.cc')
-rw-r--r-- | runtime/gc/reference_queue.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/runtime/gc/reference_queue.cc b/runtime/gc/reference_queue.cc index 4003524e5e..f4efe3c823 100644 --- a/runtime/gc/reference_queue.cc +++ b/runtime/gc/reference_queue.cc @@ -91,15 +91,30 @@ mirror::Reference* ReferenceQueue::DequeuePendingReference() { void ReferenceQueue::Dump(std::ostream& os) const { mirror::Reference* cur = list_; os << "Reference starting at list_=" << list_ << "\n"; - while (cur != nullptr) { + if (cur == nullptr) { + return; + } + do { mirror::Reference* pending_next = cur->GetPendingNext(); - os << "PendingNext=" << pending_next; + os << "Reference= " << cur << " PendingNext=" << pending_next; if (cur->IsFinalizerReferenceInstance()) { os << " Zombie=" << cur->AsFinalizerReference()->GetZombie(); } os << "\n"; cur = pending_next; + } while (cur != list_); +} + +size_t ReferenceQueue::GetLength() const { + size_t count = 0; + mirror::Reference* cur = list_; + if (cur != nullptr) { + do { + ++count; + cur = cur->GetPendingNext(); + } while (cur != list_); } + return count; } void ReferenceQueue::ClearWhiteReferences(ReferenceQueue* cleared_references, |