< prev index next >

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

Print this page

        

*** 497,541 **** clear(); return true; } return false; } - - FreeIdSet::FreeIdSet(uint size, Monitor* mon) : - _size(size), _mon(mon), _hd(0), _waiters(0), _claimed(0) - { - guarantee(size != 0, "must be"); - _ids = NEW_C_HEAP_ARRAY(uint, size, mtGC); - for (uint i = 0; i < size - 1; i++) { - _ids[i] = i+1; - } - _ids[size-1] = end_of_list; // end of list. - } - - FreeIdSet::~FreeIdSet() { - FREE_C_HEAP_ARRAY(uint, _ids); - } - - uint FreeIdSet::claim_par_id() { - MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag); - while (_hd == end_of_list) { - _waiters++; - _mon->wait(Mutex::_no_safepoint_check_flag); - _waiters--; - } - uint res = _hd; - _hd = _ids[res]; - _ids[res] = claimed; // For debugging. - _claimed++; - return res; - } - - void FreeIdSet::release_par_id(uint id) { - MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag); - assert(_ids[id] == claimed, "Precondition."); - _ids[id] = _hd; - _hd = id; - _claimed--; - if (_waiters > 0) { - _mon->notify_all(); - } - } --- 497,501 ----
< prev index next >