< prev index next >

src/hotspot/share/gc/shared/taskqueue.cpp

Print this page




 117   _n_threads(n_threads),
 118   _queue_set(queue_set),
 119   _offered_termination(0) {}
 120 
 121 ParallelTaskTerminator::~ParallelTaskTerminator() {
 122   assert(_offered_termination == 0 || !peek_in_queue_set(), "Precondition");
 123   assert(_offered_termination == 0 || _offered_termination == _n_threads, "Terminated or aborted" );
 124 }
 125 
 126 bool ParallelTaskTerminator::peek_in_queue_set() {
 127   return _queue_set->peek();
 128 }
 129 
 130 void ParallelTaskTerminator::yield() {
 131   assert(_offered_termination <= _n_threads, "Invariant");
 132   os::naked_yield();
 133 }
 134 
 135 void ParallelTaskTerminator::sleep(uint millis) {
 136   assert(_offered_termination <= _n_threads, "Invariant");
 137   os::sleep(Thread::current(), millis, false);
 138 }
 139 
 140 bool
 141 ParallelTaskTerminator::offer_termination(TerminatorTerminator* terminator) {
 142   assert(_n_threads > 0, "Initialization is incorrect");
 143   assert(_offered_termination < _n_threads, "Invariant");
 144   Atomic::inc(&_offered_termination);
 145 
 146   uint yield_count = 0;
 147   // Number of hard spin loops done since last yield
 148   uint hard_spin_count = 0;
 149   // Number of iterations in the hard spin loop.
 150   uint hard_spin_limit = WorkStealingHardSpins;
 151 
 152   // If WorkStealingSpinToYieldRatio is 0, no hard spinning is done.
 153   // If it is greater than 0, then start with a small number
 154   // of spins and increase number with each turn at spinning until
 155   // the count of hard spins exceeds WorkStealingSpinToYieldRatio.
 156   // Then do a yield() call and start spinning afresh.
 157   if (WorkStealingSpinToYieldRatio > 0) {


 263   return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
 264       _index < objArrayOop(_obj)->length();
 265 }
 266 #endif // ASSERT
 267 
 268 void ParallelTaskTerminator::reset_for_reuse(uint n_threads) {
 269   reset_for_reuse();
 270   _n_threads = n_threads;
 271 }
 272 
 273 TaskTerminator::TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
 274   _terminator(UseOWSTTaskTerminator ? new OWSTTaskTerminator(n_threads, queue_set)
 275                                     : new ParallelTaskTerminator(n_threads, queue_set)) {
 276 }
 277 
 278 TaskTerminator::~TaskTerminator() {
 279   if (_terminator != NULL) {
 280     delete _terminator;
 281   }
 282 }
 283 


 117   _n_threads(n_threads),
 118   _queue_set(queue_set),
 119   _offered_termination(0) {}
 120 
 121 ParallelTaskTerminator::~ParallelTaskTerminator() {
 122   assert(_offered_termination == 0 || !peek_in_queue_set(), "Precondition");
 123   assert(_offered_termination == 0 || _offered_termination == _n_threads, "Terminated or aborted" );
 124 }
 125 
 126 bool ParallelTaskTerminator::peek_in_queue_set() {
 127   return _queue_set->peek();
 128 }
 129 
 130 void ParallelTaskTerminator::yield() {
 131   assert(_offered_termination <= _n_threads, "Invariant");
 132   os::naked_yield();
 133 }
 134 
 135 void ParallelTaskTerminator::sleep(uint millis) {
 136   assert(_offered_termination <= _n_threads, "Invariant");
 137   os::naked_sleep(millis);
 138 }
 139 
 140 bool
 141 ParallelTaskTerminator::offer_termination(TerminatorTerminator* terminator) {
 142   assert(_n_threads > 0, "Initialization is incorrect");
 143   assert(_offered_termination < _n_threads, "Invariant");
 144   Atomic::inc(&_offered_termination);
 145 
 146   uint yield_count = 0;
 147   // Number of hard spin loops done since last yield
 148   uint hard_spin_count = 0;
 149   // Number of iterations in the hard spin loop.
 150   uint hard_spin_limit = WorkStealingHardSpins;
 151 
 152   // If WorkStealingSpinToYieldRatio is 0, no hard spinning is done.
 153   // If it is greater than 0, then start with a small number
 154   // of spins and increase number with each turn at spinning until
 155   // the count of hard spins exceeds WorkStealingSpinToYieldRatio.
 156   // Then do a yield() call and start spinning afresh.
 157   if (WorkStealingSpinToYieldRatio > 0) {


 263   return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
 264       _index < objArrayOop(_obj)->length();
 265 }
 266 #endif // ASSERT
 267 
 268 void ParallelTaskTerminator::reset_for_reuse(uint n_threads) {
 269   reset_for_reuse();
 270   _n_threads = n_threads;
 271 }
 272 
 273 TaskTerminator::TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
 274   _terminator(UseOWSTTaskTerminator ? new OWSTTaskTerminator(n_threads, queue_set)
 275                                     : new ParallelTaskTerminator(n_threads, queue_set)) {
 276 }
 277 
 278 TaskTerminator::~TaskTerminator() {
 279   if (_terminator != NULL) {
 280     delete _terminator;
 281   }
 282 }

< prev index next >