200 |
|
/** Returns true if successfully pushed c onto stack. */ |
201 |
|
final boolean tryPushStack(Completion c) { |
202 |
|
Completion h = stack; |
203 |
< |
c.lazySetNext(h); |
203 |
> |
lazySetNext(c, h); |
204 |
|
return UNSAFE.compareAndSwapObject(this, STACK, h, c); |
205 |
|
} |
206 |
|
|
414 |
|
public final boolean exec() { tryFire(ASYNC); return true; } |
415 |
|
public final Void getRawResult() { return null; } |
416 |
|
public final void setRawResult(Void v) {} |
417 |
+ |
} |
418 |
|
|
419 |
< |
void lazySetNext(Completion val) { |
420 |
< |
UNSAFE.putOrderedObject(this, NEXT, val); |
420 |
< |
} |
421 |
< |
|
422 |
< |
// Unsafe mechanics |
423 |
< |
|
424 |
< |
private static final sun.misc.Unsafe UNSAFE; |
425 |
< |
private static final long NEXT; |
426 |
< |
|
427 |
< |
static { |
428 |
< |
try { |
429 |
< |
UNSAFE = sun.misc.Unsafe.getUnsafe(); |
430 |
< |
NEXT = UNSAFE.objectFieldOffset |
431 |
< |
(Completion.class.getDeclaredField("next")); |
432 |
< |
} catch (Exception e) { |
433 |
< |
throw new Error(e); |
434 |
< |
} |
435 |
< |
} |
419 |
> |
static void lazySetNext(Completion c, Completion next) { |
420 |
> |
UNSAFE.putOrderedObject(c, NEXT, next); |
421 |
|
} |
422 |
|
|
423 |
|
/** |
509 |
|
final void push(UniCompletion<?,?> c) { |
510 |
|
if (c != null) { |
511 |
|
while (result == null && !tryPushStack(c)) |
512 |
< |
c.lazySetNext(null); // clear on failure |
512 |
> |
lazySetNext(c, null); // clear on failure |
513 |
|
} |
514 |
|
} |
515 |
|
|
996 |
|
if (c != null) { |
997 |
|
Object r; |
998 |
|
while ((r = result) == null && !tryPushStack(c)) |
999 |
< |
c.lazySetNext(null); // clear on failure |
999 |
> |
lazySetNext(c, null); // clear on failure |
1000 |
|
if (b != null && b != this && b.result == null) { |
1001 |
|
Completion q = (r != null) ? c : new CoCompletion(c); |
1002 |
|
while (b.result == null && !b.tryPushStack(q)) |
1003 |
< |
q.lazySetNext(null); // clear on failure |
1003 |
> |
lazySetNext(q, null); // clear on failure |
1004 |
|
} |
1005 |
|
} |
1006 |
|
} |
1287 |
|
Completion q = new CoCompletion(c); |
1288 |
|
while (result == null && b.result == null && |
1289 |
|
!b.tryPushStack(q)) |
1290 |
< |
q.lazySetNext(null); // clear on failure |
1290 |
> |
lazySetNext(q, null); // clear on failure |
1291 |
|
} |
1292 |
|
break; |
1293 |
|
} |
1294 |
< |
c.lazySetNext(null); // clear on failure |
1294 |
> |
lazySetNext(c, null); // clear on failure |
1295 |
|
} |
1296 |
|
} |
1297 |
|
} |
2331 |
|
private static final sun.misc.Unsafe UNSAFE; |
2332 |
|
private static final long RESULT; |
2333 |
|
private static final long STACK; |
2334 |
+ |
private static final long NEXT; |
2335 |
|
static { |
2336 |
|
try { |
2337 |
|
UNSAFE = sun.misc.Unsafe.getUnsafe(); |
2340 |
|
(k.getDeclaredField("result")); |
2341 |
|
STACK = UNSAFE.objectFieldOffset |
2342 |
|
(k.getDeclaredField("stack")); |
2343 |
+ |
NEXT = UNSAFE.objectFieldOffset |
2344 |
+ |
(Completion.class.getDeclaredField("next")); |
2345 |
|
} catch (Exception x) { |
2346 |
|
throw new Error(x); |
2347 |
|
} |