src/share/vm/gc_implementation/g1/heapRegion.hpp

Print this page
rev 7056 : [mq]: 8058298
rev 7057 : imported patch review


 759 // HeapRegionClosure is used for iterating over regions.
 760 // Terminates the iteration when the "doHeapRegion" method returns "true".
 761 class HeapRegionClosure : public StackObj {
 762   friend class HeapRegionManager;
 763   friend class G1CollectedHeap;
 764 
 765   bool _complete;
 766   void incomplete() { _complete = false; }
 767 
 768  public:
 769   HeapRegionClosure(): _complete(true) {}
 770 
 771   // Typically called on each region until it returns true.
 772   virtual bool doHeapRegion(HeapRegion* r) = 0;
 773 
 774   // True after iteration if the closure was applied to all heap regions
 775   // and returned "false" in all cases.
 776   bool complete() { return _complete; }
 777 };
 778 
 779 // The HeapRegionClaimer is used during parallel iteration over heap regions,
 780 // allowing workers to claim heap regions, gaining exclusive rights to these regions.
 781 class HeapRegionClaimer {
 782   uint  _n_workers;
 783   uint  _n_regions;
 784   uint* _claims;
 785 
 786   static const uint Unclaimed = 0;
 787   static const uint Claimed   = 1;
 788 
 789  public:
 790   HeapRegionClaimer() : _n_workers(0), _n_regions(0), _claims(NULL) {}
 791 
 792   HeapRegionClaimer(uint n_workers) : _n_workers(n_workers), _n_regions(0), _claims(NULL) {
 793       initialize(n_workers);
 794   }
 795 
 796   ~HeapRegionClaimer() {
 797     if (_claims != NULL) {
 798       FREE_C_HEAP_ARRAY(uint, _claims, mtGC);
 799     }
 800   }
 801 
 802   inline uint n_regions() const {
 803     return _n_regions;
 804   }
 805 
 806   inline void initialize(uint n_workers);
 807 
 808   // Calculate the starting region for given worker so
 809   // that they do not all start from the same region.
 810   inline uint start_region_for_worker(uint worker_id) const;
 811 
 812   // Check if region has been claimed with this HRClaimer.
 813   inline bool is_region_claimed(uint region_index) const;
 814 
 815   // Claim the given region, returns true if successfully claimed.
 816   inline bool claim_region(uint region_index);
 817 };
 818 
 819 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP


 759 // HeapRegionClosure is used for iterating over regions.
 760 // Terminates the iteration when the "doHeapRegion" method returns "true".
 761 class HeapRegionClosure : public StackObj {
 762   friend class HeapRegionManager;
 763   friend class G1CollectedHeap;
 764 
 765   bool _complete;
 766   void incomplete() { _complete = false; }
 767 
 768  public:
 769   HeapRegionClosure(): _complete(true) {}
 770 
 771   // Typically called on each region until it returns true.
 772   virtual bool doHeapRegion(HeapRegion* r) = 0;
 773 
 774   // True after iteration if the closure was applied to all heap regions
 775   // and returned "false" in all cases.
 776   bool complete() { return _complete; }
 777 };
 778 








































 779 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP