117 verify_ok_to_terminate();
118 }
119
120 #ifndef PRODUCT
121 void ConcurrentMarkSweepThread::verify_ok_to_terminate() const {
122 assert(!(CGC_lock->owned_by_self() || cms_thread_has_cms_token() ||
123 cms_thread_wants_cms_token()),
124 "Must renounce all worldly possessions and desires for nirvana");
125 _collector->verify_ok_to_terminate();
126 }
127 #endif
128
129 // create and start a new ConcurrentMarkSweep Thread for given CMS generation
130 ConcurrentMarkSweepThread* ConcurrentMarkSweepThread::start(CMSCollector* collector) {
131 guarantee(_cmst == NULL, "start() called twice!");
132 ConcurrentMarkSweepThread* th = new ConcurrentMarkSweepThread(collector);
133 assert(_cmst == th, "Where did the just-created CMS thread go?");
134 return th;
135 }
136
137 void ConcurrentMarkSweepThread::stop_all() {
138 assert(_cmst != NULL, "stop_all should be called after initialization");
139 _cmst->stop();
140 }
141
142 void ConcurrentMarkSweepThread::stop_service() {
143 // Now post a notify on CGC_lock so as to nudge
144 // CMS thread(s) that might be slumbering in
145 // sleepBeforeNextCycle.
146 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
147 CGC_lock->notify_all();
148 }
149
150 void ConcurrentMarkSweepThread::threads_do(ThreadClosure* tc) {
151 assert(tc != NULL, "Null ThreadClosure");
152 if (cmst() != NULL && !cmst()->has_terminated()) {
153 tc->do_thread(cmst());
154 }
155 assert(Universe::is_fully_initialized(),
156 "Called too early, make sure heap is fully initialized");
157 if (_collector != NULL) {
158 AbstractWorkGang* gang = _collector->conc_workers();
159 if (gang != NULL) {
160 gang->threads_do(tc);
161 }
|
117 verify_ok_to_terminate();
118 }
119
120 #ifndef PRODUCT
121 void ConcurrentMarkSweepThread::verify_ok_to_terminate() const {
122 assert(!(CGC_lock->owned_by_self() || cms_thread_has_cms_token() ||
123 cms_thread_wants_cms_token()),
124 "Must renounce all worldly possessions and desires for nirvana");
125 _collector->verify_ok_to_terminate();
126 }
127 #endif
128
129 // create and start a new ConcurrentMarkSweep Thread for given CMS generation
130 ConcurrentMarkSweepThread* ConcurrentMarkSweepThread::start(CMSCollector* collector) {
131 guarantee(_cmst == NULL, "start() called twice!");
132 ConcurrentMarkSweepThread* th = new ConcurrentMarkSweepThread(collector);
133 assert(_cmst == th, "Where did the just-created CMS thread go?");
134 return th;
135 }
136
137 void ConcurrentMarkSweepThread::stop_service() {
138 // Now post a notify on CGC_lock so as to nudge
139 // CMS thread(s) that might be slumbering in
140 // sleepBeforeNextCycle.
141 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
142 CGC_lock->notify_all();
143 }
144
145 void ConcurrentMarkSweepThread::threads_do(ThreadClosure* tc) {
146 assert(tc != NULL, "Null ThreadClosure");
147 if (cmst() != NULL && !cmst()->has_terminated()) {
148 tc->do_thread(cmst());
149 }
150 assert(Universe::is_fully_initialized(),
151 "Called too early, make sure heap is fully initialized");
152 if (_collector != NULL) {
153 AbstractWorkGang* gang = _collector->conc_workers();
154 if (gang != NULL) {
155 gang->threads_do(tc);
156 }
|