< prev index next >
src/hotspot/share/gc/shared/owstTaskTerminator.cpp
Print this page
@@ -33,18 +33,19 @@
bool OWSTTaskTerminator::offer_termination(TerminatorTerminator* terminator) {
assert(_n_threads > 0, "Initialization is incorrect");
assert(_offered_termination < _n_threads, "Invariant");
assert(_blocker != NULL, "Invariant");
- // single worker, done
+ // Single worker, done.
if (_n_threads == 1) {
return true;
}
_blocker->lock_without_safepoint_check();
- // all arrived, done
- if (++ _offered_termination == _n_threads) {
+ // All terminated, done.
+ _offered_termination++;
+ if (_offered_termination == _n_threads) {
_blocker->notify_all();
_blocker->unlock();
return true;
}
@@ -70,11 +71,11 @@
}
}
size_t tasks = tasks_in_queue_set();
if (exit_termination(tasks, terminator)) {
- _offered_termination --;
+ _offered_termination--;
_blocker->unlock();
return false;
}
}
}
@@ -135,11 +136,11 @@
} else {
log_develop_trace(gc, task)("OWSTTaskTerminator::do_spin_master_work() thread " PTR_FORMAT " sleeps after %u yields",
p2i(Thread::current()), yield_count);
yield_count = 0;
- MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag); // no safepoint check
+ MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag);
_spin_master = NULL;
locker.wait(Mutex::_no_safepoint_check_flag, WorkStealingSleepMillis);
if (_spin_master == NULL) {
_spin_master = Thread::current();
} else {
@@ -150,11 +151,11 @@
#ifdef TRACESPINNING
_total_peeks++;
#endif
size_t tasks = tasks_in_queue_set();
if (exit_termination(tasks, terminator)) {
- MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag); // no safepoint check
+ MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag);
if (tasks >= _offered_termination - 1) {
locker.notify_all();
} else {
for (; tasks > 1; tasks --) {
< prev index next >