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 |
|
} |