2982 |
|
*/ |
2983 |
|
public boolean cancel(boolean mayInterruptIfRunning) { |
2984 |
|
Object r; |
2985 |
< |
while ((r = result) == null) { |
2986 |
< |
r = new AltResult(new CancellationException()); |
2987 |
< |
if (UNSAFE.compareAndSwapObject(this, RESULT, null, r)) { |
2988 |
< |
postComplete(); |
2989 |
< |
return true; |
2990 |
< |
} |
2991 |
< |
} |
2992 |
< |
return ((r instanceof AltResult) && |
2993 |
< |
(((AltResult)r).ex instanceof CancellationException)); |
2985 |
> |
boolean cancelled = (result == null) && |
2986 |
> |
UNSAFE.compareAndSwapObject |
2987 |
> |
(this, RESULT, null, new AltResult(new CancellationException())); |
2988 |
> |
postComplete(); |
2989 |
> |
return cancelled || |
2990 |
> |
(((r = result) instanceof AltResult) && |
2991 |
> |
(((AltResult)r).ex instanceof CancellationException)); |
2992 |
|
} |
2993 |
|
|
2994 |
|
/** |