759 |
|
static final int MAXIMUM_QUEUE_CAPACITY = 1 << 26; // 64M |
760 |
|
|
761 |
|
// Instance fields |
762 |
+ |
|
763 |
|
volatile int scanState; // versioned, negative if inactive |
764 |
|
int stackPred; // pool stack (ctl) predecessor |
765 |
|
int nsteals; // number of steals |
773 |
|
final ForkJoinWorkerThread owner; // owning thread or null if shared |
774 |
|
volatile Thread parker; // == owner during call to park; else null |
775 |
|
volatile ForkJoinTask<?> currentJoin; // task being joined in awaitJoin |
776 |
< |
volatile ForkJoinTask<?> currentSteal; // mainly used by helpStealer |
776 |
> |
@sun.misc.Contended("group2") // separate from other fields |
777 |
> |
volatile ForkJoinTask<?> currentSteal; // nonnull when running some task |
778 |
|
|
779 |
|
WorkQueue(ForkJoinPool pool, ForkJoinWorkerThread owner) { |
780 |
|
this.pool = pool; |
1035 |
|
U.getAndSetObject(a, offset, null); |
1036 |
|
if (t != null) { |
1037 |
|
base = b; |
1038 |
< |
(currentSteal = t).doExec(); |
1038 |
> |
t.doExec(); |
1039 |
|
if (++nexec > POLL_LIMIT) |
1040 |
|
break; |
1041 |
|
} |
1649 |
|
long c; int sp, wl, m; WorkQueue v; |
1650 |
|
if ((sp = (int)(c = ctl)) != 0 && w != null && |
1651 |
|
ws != null && (wl = ws.length) > 0 && |
1652 |
< |
((m = wl - 1) & ((sp ^ r) >>> 16)) == 0 && |
1652 |
> |
((m = wl - 1) & ((sp ^ r) >>> 16)) <= 1 && |
1653 |
|
(v = ws[m & sp]) != null) { |
1654 |
|
long nc = (v.stackPred & SP_MASK) | (UC_MASK & (c + AC_UNIT)); |
1655 |
|
int ns = sp & ~UNSIGNALLED; |
1866 |
|
if (t == null || b++ != q.base) |
1867 |
|
break; // busy or empty |
1868 |
|
else if (ss < 0) { |
1869 |
< |
tryReactivate(w, ws, r); |
1870 |
< |
break; // retry upon rescan |
1869 |
> |
if ((ss = w.scanState) >= 0) { |
1870 |
> |
tryReactivate(w, ws, r); |
1871 |
> |
break; // retry upon rescan |
1872 |
> |
} |
1873 |
> |
r |= (1 << 31); // ensure full scan |
1874 |
|
} |
1875 |
|
else if (!U.compareAndSwapObject(a, offset, t, null)) |
1876 |
|
break; // contended |