< prev index next >
src/share/vm/gc/shared/workgroup.cpp
Print this page
@@ -432,26 +432,20 @@
}
// SubTasksDone functions.
SubTasksDone::SubTasksDone(uint n) :
- _n_tasks(n), _n_threads(1), _tasks(NULL) {
+ _n_tasks(n), _tasks(NULL) {
_tasks = NEW_C_HEAP_ARRAY(uint, n, mtInternal);
guarantee(_tasks != NULL, "alloc failure");
clear();
}
bool SubTasksDone::valid() {
return _tasks != NULL;
}
-void SubTasksDone::set_n_threads(uint t) {
- assert(_claimed == 0 || _threads_completed == _n_threads,
- "should not be called while tasks are being processed!");
- _n_threads = (t == 0 ? 1 : t);
-}
-
void SubTasksDone::clear() {
for (uint i = 0; i < _n_tasks; i++) {
_tasks[i] = 0;
}
_threads_completed = 0;
@@ -475,19 +469,22 @@
}
#endif
return res;
}
-void SubTasksDone::all_tasks_completed() {
+void SubTasksDone::all_tasks_completed(uint n_threads) {
jint observed = _threads_completed;
jint old;
do {
old = observed;
observed = Atomic::cmpxchg(old+1, &_threads_completed, old);
} while (observed != old);
// If this was the last thread checking in, clear the tasks.
- if (observed+1 == (jint)_n_threads) clear();
+ uint adjusted_thread_count = (n_threads == 0 ? 1 : n_threads);
+ if (observed + 1 == (jint)adjusted_thread_count) {
+ clear();
+ }
}
SubTasksDone::~SubTasksDone() {
if (_tasks != NULL) FREE_C_HEAP_ARRAY(jint, _tasks);
< prev index next >