< prev index next > src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
Print this page
*/
final void push(ForkJoinTask<?> task, ForkJoinPool pool, boolean internal) {
int s = top, b = base, m, cap, room; ForkJoinTask<?>[] a;
if ((a = array) != null && (cap = a.length) > 0 && // else disabled
task != null) {
- int pk = task.noUserHelp() + 1; // prev slot offset
if ((room = (m = cap - 1) - (s - b)) >= 0) {
top = s + 1;
long pos = slotOffset(m & s);
if (!internal)
U.putReference(a, pos, task); // inside lock
}
if (!internal)
unlockPhase();
if (room < 0)
throw new RejectedExecutionException("Queue capacity exceeded");
- if ((room == 0 || a[m & (s - pk)] == null) &&
- pool != null)
+ if (pool != null &&
+ (room == 0 ||
+ U.getReferenceVolatile(a, slotOffset(m & (s - 1))) == null))
pool.signalWork(); // may have appeared empty
}
}
/**
< prev index next >