ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ForkJoinPool.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.391 by dl, Sun Dec 27 20:14:39 2020 UTC vs.
Revision 1.392 by dl, Sun Jan 31 13:35:43 2021 UTC

# Line 1017 | Line 1017 | public class ForkJoinPool extends Abstra
1017           */
1018          final boolean externalTryUnpush(ForkJoinTask<?> task) {
1019              boolean taken = false;
1020 <            int s = top, cap, k; ForkJoinTask<?>[] a;
1021 <            if ((a = array) != null && (cap = a.length) > 0 &&
1022 <                a[k = (cap - 1) & (s - 1)] == task && tryLock()) {
1023 <                if (top == s && array == a &&
1024 <                    (taken = casSlotToNull(a, k, task)))
1025 <                    top = s - 1;
1026 <                source = 0; // release lock
1020 >            for (;;) {
1021 >                int s = top, cap, k; ForkJoinTask<?>[] a;
1022 >                if ((a = array) == null || (cap = a.length) <= 0 ||
1023 >                    a[k = (cap - 1) & (s - 1)] != task)
1024 >                    break;
1025 >                if (tryLock()) {
1026 >                    if (top == s && array == a &&
1027 >                        (taken = casSlotToNull(a, k, task)))
1028 >                        top = s - 1;
1029 >                    source = 0; // release lock
1030 >                    break;
1031 >                }
1032 >                Thread.yield(); // trylock failure
1033              }
1034              return taken;
1035          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines