hotspot/src/share/vm/utilities/workgroup.cpp
bool SubTasksDone::is_task_claimed(int t) {
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(0 <= t && t < _n_tasks, "bad task id.");
{- -------------------------------------------
(1) まだ該当の仕事が未処理(以下の, old == 0)であれば, Atomic::cmpxchg() でその仕事を取りにいく.
---------------------------------------- -}
jint old = _tasks[t];
if (old == 0) {
old = Atomic::cmpxchg(1, &_tasks[t], 0);
}
assert(_tasks[t] == 1, "What else?");
{- -------------------------------------------
(1) Atomic::cmpxchg() での仕事の取得が成功していれば 1 を返す.
そうでなければ(元々未処理では無かった場合 or Atomic::cmpxchg() で取れなかった場合) 0 を返す.
---------------------------------------- -}
bool res = old != 0;
#ifdef ASSERT
if (!res) {
assert(_claimed < _n_tasks, "Too many tasks claimed; missing clear?");
Atomic::inc(&_claimed);
}
#endif
return res;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.