提交 2c8e932e 编写于 作者: D dl

7037436: CR 7035020 fails to check shutdown

Reviewed-by: chegar
上级 59d00fca
...@@ -824,7 +824,8 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -824,7 +824,8 @@ public class ForkJoinPool extends AbstractExecutorService {
else if (w.eventCount != v) else if (w.eventCount != v)
return true; // update next time return true; // update next time
} }
if ((int)c != 0 && parallelism + (int)(nc >> AC_SHIFT) == 0 && if ((!shutdown || !tryTerminate(false)) &&
(int)c != 0 && parallelism + (int)(nc >> AC_SHIFT) == 0 &&
blockedCount == 0 && quiescerCount == 0) blockedCount == 0 && quiescerCount == 0)
idleAwaitWork(w, nc, c, v); // quiescent idleAwaitWork(w, nc, c, v); // quiescent
for (boolean rescanned = false;;) { for (boolean rescanned = false;;) {
...@@ -1024,8 +1025,8 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1024,8 +1025,8 @@ public class ForkJoinPool extends AbstractExecutorService {
do {} while (!UNSAFE.compareAndSwapLong(this, ctlOffset, // no mask do {} while (!UNSAFE.compareAndSwapLong(this, ctlOffset, // no mask
c = ctl, c + AC_UNIT)); c = ctl, c + AC_UNIT));
int b; int b;
do {} while(!UNSAFE.compareAndSwapInt(this, blockedCountOffset, do {} while (!UNSAFE.compareAndSwapInt(this, blockedCountOffset,
b = blockedCount, b - 1)); b = blockedCount, b - 1));
} }
/** /**
...@@ -1177,7 +1178,7 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1177,7 +1178,7 @@ public class ForkJoinPool extends AbstractExecutorService {
ws[k] = w; ws[k] = w;
nextWorkerIndex = k + 1; nextWorkerIndex = k + 1;
int m = g & SMASK; int m = g & SMASK;
g = k > m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1); g = (k > m) ? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1);
} }
} finally { } finally {
scanGuard = g; scanGuard = g;
...@@ -1360,8 +1361,8 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1360,8 +1361,8 @@ public class ForkJoinPool extends AbstractExecutorService {
*/ */
final void addQuiescerCount(int delta) { final void addQuiescerCount(int delta) {
int c; int c;
do {} while(!UNSAFE.compareAndSwapInt(this, quiescerCountOffset, do {} while (!UNSAFE.compareAndSwapInt(this, quiescerCountOffset,
c = quiescerCount, c + delta)); c = quiescerCount, c + delta));
} }
/** /**
...@@ -1714,7 +1715,7 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1714,7 +1715,7 @@ public class ForkJoinPool extends AbstractExecutorService {
*/ */
public int getRunningThreadCount() { public int getRunningThreadCount() {
int r = parallelism + (int)(ctl >> AC_SHIFT); int r = parallelism + (int)(ctl >> AC_SHIFT);
return r <= 0? 0 : r; // suppress momentarily negative values return (r <= 0) ? 0 : r; // suppress momentarily negative values
} }
/** /**
...@@ -1726,7 +1727,7 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1726,7 +1727,7 @@ public class ForkJoinPool extends AbstractExecutorService {
*/ */
public int getActiveThreadCount() { public int getActiveThreadCount() {
int r = parallelism + (int)(ctl >> AC_SHIFT) + blockedCount; int r = parallelism + (int)(ctl >> AC_SHIFT) + blockedCount;
return r <= 0? 0 : r; // suppress momentarily negative values return (r <= 0) ? 0 : r; // suppress momentarily negative values
} }
/** /**
...@@ -1881,9 +1882,9 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1881,9 +1882,9 @@ public class ForkJoinPool extends AbstractExecutorService {
int ac = rc + blockedCount; int ac = rc + blockedCount;
String level; String level;
if ((c & STOP_BIT) != 0) if ((c & STOP_BIT) != 0)
level = (tc == 0)? "Terminated" : "Terminating"; level = (tc == 0) ? "Terminated" : "Terminating";
else else
level = shutdown? "Shutting down" : "Running"; level = shutdown ? "Shutting down" : "Running";
return super.toString() + return super.toString() +
"[" + level + "[" + level +
", parallelism = " + pc + ", parallelism = " + pc +
......
...@@ -361,7 +361,7 @@ public class ForkJoinWorkerThread extends Thread { ...@@ -361,7 +361,7 @@ public class ForkJoinWorkerThread extends Thread {
protected void onStart() { protected void onStart() {
queue = new ForkJoinTask<?>[INITIAL_QUEUE_CAPACITY]; queue = new ForkJoinTask<?>[INITIAL_QUEUE_CAPACITY];
int r = pool.workerSeedGenerator.nextInt(); int r = pool.workerSeedGenerator.nextInt();
seed = (r == 0)? 1 : r; // must be nonzero seed = (r == 0) ? 1 : r; // must be nonzero
} }
/** /**
...@@ -724,7 +724,7 @@ public class ForkJoinWorkerThread extends Thread { ...@@ -724,7 +724,7 @@ public class ForkJoinWorkerThread extends Thread {
Thread.yield(); // for politeness Thread.yield(); // for politeness
} }
else else
retries = helpJoinTask(joinMe)? MAX_HELP : retries - 1; retries = helpJoinTask(joinMe) ? MAX_HELP : retries - 1;
} }
else { else {
retries = MAX_HELP; // restart if not done retries = MAX_HELP; // restart if not done
...@@ -955,7 +955,7 @@ public class ForkJoinWorkerThread extends Thread { ...@@ -955,7 +955,7 @@ public class ForkJoinWorkerThread extends Thread {
p.addActiveCount(1); p.addActiveCount(1);
} }
if ((t = (v != this) ? v.deqTask() : if ((t = (v != this) ? v.deqTask() :
locallyFifo? locallyDeqTask() : popTask()) != null) { locallyFifo ? locallyDeqTask() : popTask()) != null) {
currentSteal = t; currentSteal = t;
t.doExec(); t.doExec();
currentSteal = ps; currentSteal = ps;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册