hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp
changeset 25351 7c198a690050
parent 24093 095cc0a63ed9
child 27251 7d667f91ec8d
--- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp	Thu Jun 19 13:31:14 2014 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp	Wed Jun 04 11:56:44 2014 +0200
@@ -31,6 +31,7 @@
 #include "gc_implementation/g1/g1StringDedupStat.hpp"
 #include "gc_implementation/g1/g1StringDedupTable.hpp"
 #include "gc_implementation/g1/g1StringDedupThread.hpp"
+#include "runtime/atomic.inline.hpp"
 
 bool G1StringDedup::_enabled = false;
 
@@ -211,3 +212,16 @@
     G1StringDedupTable::finish_rehash(_rehashed_table);
   }
 }
+
+// Atomically claims the next available queue for exclusive access by
+// the current thread. Returns the queue number of the claimed queue.
+size_t G1StringDedupUnlinkOrOopsDoClosure::claim_queue() {
+  return (size_t)Atomic::add_ptr(1, &_next_queue) - 1;
+}
+
+// Atomically claims the next available table partition for exclusive
+// access by the current thread. Returns the table bucket number where
+// the claimed partition starts.
+size_t G1StringDedupUnlinkOrOopsDoClosure::claim_table_partition(size_t partition_size) {
+  return (size_t)Atomic::add_ptr(partition_size, &_next_bucket) - partition_size;
+}