127 if (_should_terminate) break; 128 GCIdMark gc_id_mark; 129 GCCause::Cause cause = _collector->_full_gc_requested ? 130 _collector->_full_gc_cause : GCCause::_cms_concurrent_mark; 131 _collector->collect_in_background(cause); 132 } 133 assert(_should_terminate, "just checking"); 134 // Check that the state of any protocol for synchronization 135 // between background (CMS) and foreground collector is "clean" 136 // (i.e. will not potentially block the foreground collector, 137 // requiring action by us). 138 verify_ok_to_terminate(); 139 // Signal that it is terminated 140 { 141 MutexLockerEx mu(Terminator_lock, 142 Mutex::_no_safepoint_check_flag); 143 assert(_cmst == this, "Weird!"); 144 _cmst = NULL; 145 Terminator_lock->notify(); 146 } 147 148 // Thread destructor usually does this.. 149 ThreadLocalStorage::set_thread(NULL); 150 } 151 152 #ifndef PRODUCT 153 void ConcurrentMarkSweepThread::verify_ok_to_terminate() const { 154 assert(!(CGC_lock->owned_by_self() || cms_thread_has_cms_token() || 155 cms_thread_wants_cms_token()), 156 "Must renounce all worldly possessions and desires for nirvana"); 157 _collector->verify_ok_to_terminate(); 158 } 159 #endif 160 161 // create and start a new ConcurrentMarkSweep Thread for given CMS generation 162 ConcurrentMarkSweepThread* ConcurrentMarkSweepThread::start(CMSCollector* collector) { 163 if (!_should_terminate) { 164 assert(cmst() == NULL, "start() called twice?"); 165 ConcurrentMarkSweepThread* th = new ConcurrentMarkSweepThread(collector); 166 assert(cmst() == th, "Where did the just-created CMS thread go?"); 167 return th; 168 } 169 return NULL; | 127 if (_should_terminate) break; 128 GCIdMark gc_id_mark; 129 GCCause::Cause cause = _collector->_full_gc_requested ? 130 _collector->_full_gc_cause : GCCause::_cms_concurrent_mark; 131 _collector->collect_in_background(cause); 132 } 133 assert(_should_terminate, "just checking"); 134 // Check that the state of any protocol for synchronization 135 // between background (CMS) and foreground collector is "clean" 136 // (i.e. will not potentially block the foreground collector, 137 // requiring action by us). 138 verify_ok_to_terminate(); 139 // Signal that it is terminated 140 { 141 MutexLockerEx mu(Terminator_lock, 142 Mutex::_no_safepoint_check_flag); 143 assert(_cmst == this, "Weird!"); 144 _cmst = NULL; 145 Terminator_lock->notify(); 146 } 147 } 148 149 #ifndef PRODUCT 150 void ConcurrentMarkSweepThread::verify_ok_to_terminate() const { 151 assert(!(CGC_lock->owned_by_self() || cms_thread_has_cms_token() || 152 cms_thread_wants_cms_token()), 153 "Must renounce all worldly possessions and desires for nirvana"); 154 _collector->verify_ok_to_terminate(); 155 } 156 #endif 157 158 // create and start a new ConcurrentMarkSweep Thread for given CMS generation 159 ConcurrentMarkSweepThread* ConcurrentMarkSweepThread::start(CMSCollector* collector) { 160 if (!_should_terminate) { 161 assert(cmst() == NULL, "start() called twice?"); 162 ConcurrentMarkSweepThread* th = new ConcurrentMarkSweepThread(collector); 163 assert(cmst() == th, "Where did the just-created CMS thread go?"); 164 return th; 165 } 166 return NULL; |