< prev index next >

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

Print this page

437 #endif
438   return res;
439 }
440 
441 void SubTasksDone::all_tasks_completed(uint n_threads) {
442   uint observed = _threads_completed;
443   uint old;
444   do {
445     old = observed;
446     observed = Atomic::cmpxchg(old+1, &_threads_completed, old);
447   } while (observed != old);
448   // If this was the last thread checking in, clear the tasks.
449   uint adjusted_thread_count = (n_threads == 0 ? 1 : n_threads);
450   if (observed + 1 == adjusted_thread_count) {
451     clear();
452   }
453 }
454 
455 
456 SubTasksDone::~SubTasksDone() {
457   if (_tasks != NULL) FREE_C_HEAP_ARRAY(uint, _tasks);
458 }
459 
460 // *** SequentialSubTasksDone
461 
462 void SequentialSubTasksDone::clear() {
463   _n_tasks   = _n_claimed   = 0;
464   _n_threads = _n_completed = 0;
465 }
466 
467 bool SequentialSubTasksDone::valid() {
468   return _n_threads > 0;
469 }
470 
471 bool SequentialSubTasksDone::try_claim_task(uint& t) {
472   t = _n_claimed;
473   while (t < _n_tasks) {
474     uint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
475     if (res == t) {
476       return true;
477     }

437 #endif
438   return res;
439 }
440 
441 void SubTasksDone::all_tasks_completed(uint n_threads) {
442   uint observed = _threads_completed;
443   uint old;
444   do {
445     old = observed;
446     observed = Atomic::cmpxchg(old+1, &_threads_completed, old);
447   } while (observed != old);
448   // If this was the last thread checking in, clear the tasks.
449   uint adjusted_thread_count = (n_threads == 0 ? 1 : n_threads);
450   if (observed + 1 == adjusted_thread_count) {
451     clear();
452   }
453 }
454 
455 
456 SubTasksDone::~SubTasksDone() {
457   FREE_C_HEAP_ARRAY(uint, _tasks);
458 }
459 
460 // *** SequentialSubTasksDone
461 
462 void SequentialSubTasksDone::clear() {
463   _n_tasks   = _n_claimed   = 0;
464   _n_threads = _n_completed = 0;
465 }
466 
467 bool SequentialSubTasksDone::valid() {
468   return _n_threads > 0;
469 }
470 
471 bool SequentialSubTasksDone::try_claim_task(uint& t) {
472   t = _n_claimed;
473   while (t < _n_tasks) {
474     uint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
475     if (res == t) {
476       return true;
477     }
< prev index next >