< prev index next >

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

Print this page
rev 11970 : imported patch workgroup_volatiles
rev 11971 : [mq]: workgroup_volatiles2


 455   }
 456 }
 457 
 458 
 459 SubTasksDone::~SubTasksDone() {
 460   if (_tasks != NULL) FREE_C_HEAP_ARRAY(jint, _tasks);
 461 }
 462 
 463 // *** SequentialSubTasksDone
 464 
 465 void SequentialSubTasksDone::clear() {
 466   _n_tasks   = _n_claimed   = 0;
 467   _n_threads = _n_completed = 0;
 468 }
 469 
 470 bool SequentialSubTasksDone::valid() {
 471   return _n_threads > 0;
 472 }
 473 
 474 bool SequentialSubTasksDone::is_task_claimed(uint& t) {
 475   uint* n_claimed_ptr = &_n_claimed;
 476   t = *n_claimed_ptr;
 477   while (t < _n_tasks) {
 478     jint res = Atomic::cmpxchg(t+1, n_claimed_ptr, t);
 479     if (res == (jint)t) {
 480       return false;
 481     }
 482     t = *n_claimed_ptr;
 483   }
 484   return true;
 485 }
 486 
 487 bool SequentialSubTasksDone::all_tasks_completed() {
 488   uint* n_completed_ptr = &_n_completed;
 489   uint  complete        = *n_completed_ptr;
 490   while (true) {
 491     uint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
 492     if (res == complete) {
 493       break;
 494     }
 495     complete = res;
 496   }
 497   if (complete+1 == _n_threads) {
 498     clear();
 499     return true;
 500   }
 501   return false;
 502 }


 455   }
 456 }
 457 
 458 
 459 SubTasksDone::~SubTasksDone() {
 460   if (_tasks != NULL) FREE_C_HEAP_ARRAY(jint, _tasks);
 461 }
 462 
 463 // *** SequentialSubTasksDone
 464 
 465 void SequentialSubTasksDone::clear() {
 466   _n_tasks   = _n_claimed   = 0;
 467   _n_threads = _n_completed = 0;
 468 }
 469 
 470 bool SequentialSubTasksDone::valid() {
 471   return _n_threads > 0;
 472 }
 473 
 474 bool SequentialSubTasksDone::is_task_claimed(uint& t) {
 475   uint n_claimed = _n_claimed;
 476   t = n_claimed;
 477   while (t < _n_tasks) {
 478     jint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
 479     if (res == (jint)t) {
 480       return false;
 481     }
 482     t = res;
 483   }
 484   return true;
 485 }
 486 
 487 bool SequentialSubTasksDone::all_tasks_completed() {
 488   uint complete = _n_completed;

 489   while (true) {
 490     uint res = Atomic::cmpxchg(complete+1, &_n_completed, complete);
 491     if (res == complete) {
 492       break;
 493     }
 494     complete = res;
 495   }
 496   if (complete+1 == _n_threads) {
 497     clear();
 498     return true;
 499   }
 500   return false;
 501 }
< prev index next >