@@ -1278,8 +1278,7 @@ final int queueSize() {
12781278 * @param internal if caller owns this queue
12791279 * @throws RejectedExecutionException if array could not be resized
12801280 */
1281- final void push (ForkJoinTask <?> task , ForkJoinPool pool ,
1282- boolean internal ) {
1281+ final void push (ForkJoinTask <?> task , ForkJoinPool pool , boolean internal ) {
12831282 int s = top , b = base , m , cap , room ; ForkJoinTask <?>[] a ;
12841283 if ((a = array ) != null && (cap = a .length ) > 0 && // else disabled
12851284 task != null ) {
@@ -1383,8 +1382,7 @@ final boolean tryUnpush(ForkJoinTask<?> task, boolean internal) {
13831382 if (a != null && (cap = a .length ) > 0 &&
13841383 U .getReference (a , k = slotOffset ((cap - 1 ) & s )) == task &&
13851384 (internal || tryLockPhase ())) {
1386- if (top == p &&
1387- U .compareAndSetReference (a , k , task , null )) {
1385+ if (top == p && U .compareAndSetReference (a , k , task , null )) {
13881386 taken = true ;
13891387 updateTop (s );
13901388 }
@@ -2061,8 +2059,9 @@ private int deactivate(WorkQueue w, int phase) {
20612059 ((e & SHUTDOWN ) != 0L && ac == 0 && quiescent () > 0 ) ||
20622060 (qs = queues ) == null || (n = qs .length ) <= 0 )
20632061 return IDLE ; // terminating
2064- int k = Math .max (n << 2 , SPIN_WAITS << 1 );
2065- for (int prechecks = k / n ;;) { // reactivation threshold
2062+
2063+ for (int prechecks = Math .min (ac , 2 ), // reactivation threshold
2064+ k = Math .max (n + (n << 1 ), SPIN_WAITS << 1 );;) {
20662065 WorkQueue q ; int cap ; ForkJoinTask <?>[] a ; long c ;
20672066 if (w .phase == activePhase )
20682067 return activePhase ;
@@ -2071,7 +2070,7 @@ private int deactivate(WorkQueue w, int phase) {
20712070 if ((q = qs [k & (n - 1 )]) == null )
20722071 Thread .onSpinWait ();
20732072 else if ((a = q .array ) != null && (cap = a .length ) > 0 &&
2074- a [q .base & (cap - 1 )] != null && --prechecks <= 0 &&
2073+ a [q .base & (cap - 1 )] != null && --prechecks < 0 &&
20752074 (int )(c = ctl ) == activePhase &&
20762075 compareAndSetCtl (c , (sp & LMASK ) | ((c + RC_UNIT ) & UMASK )))
20772076 return w .phase = activePhase ; // reactivate
0 commit comments