216 |
|
} |
217 |
|
|
218 |
|
void innerSet(V v) { |
219 |
< |
int s = getState(); |
220 |
< |
if (ranOrCancelled(s) || !compareAndSetState(s, RAN)) |
221 |
< |
return; |
219 |
> |
for (;;) { |
220 |
> |
int s = getState(); |
221 |
> |
if (ranOrCancelled(s)) |
222 |
> |
return; |
223 |
> |
if (compareAndSetState(s, RAN)) |
224 |
> |
break; |
225 |
> |
} |
226 |
|
result = v; |
227 |
|
releaseShared(0); |
228 |
|
done(); |
229 |
|
} |
230 |
|
|
231 |
|
void innerSetException(Throwable t) { |
232 |
< |
int s = getState(); |
233 |
< |
if (ranOrCancelled(s) || !compareAndSetState(s, RAN)) |
234 |
< |
return; |
232 |
> |
for (;;) { |
233 |
> |
int s = getState(); |
234 |
> |
if (ranOrCancelled(s)) |
235 |
> |
return; |
236 |
> |
if (compareAndSetState(s, RAN)) |
237 |
> |
break; |
238 |
> |
} |
239 |
|
exception = t; |
240 |
|
result = null; |
241 |
|
releaseShared(0); |
243 |
|
} |
244 |
|
|
245 |
|
boolean innerCancel(boolean mayInterruptIfRunning) { |
246 |
< |
int s = getState(); |
247 |
< |
if (ranOrCancelled(s) || !compareAndSetState(s, CANCELLED)) |
248 |
< |
return false; |
246 |
> |
for (;;) { |
247 |
> |
int s = getState(); |
248 |
> |
if (ranOrCancelled(s)) |
249 |
> |
return false; |
250 |
> |
if (compareAndSetState(s, CANCELLED)) |
251 |
> |
break; |
252 |
> |
} |
253 |
|
if (mayInterruptIfRunning) { |
254 |
|
Thread r = runner; |
255 |
|
if (r != null) |