--- jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/10/28 22:35:45 1.70
+++ jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/10/30 14:23:03 1.71
@@ -5,9 +5,7 @@
*/
package jsr166e;
-import jsr166e.LongAdder;
-import jsr166e.ForkJoinPool;
-import jsr166e.ForkJoinTask;
+
import java.util.Comparator;
import java.util.Arrays;
import java.util.Map;
@@ -84,7 +82,7 @@ import java.io.Serializable;
* {@code hashCode()} is a sure way to slow down performance of any
* hash table.
*
- *
A {@link Set} projection of a ConcurrentHashMap may be created
+ *
A {@link Set} projection of a ConcurrentHashMapV8 may be created
* (using {@link #newKeySet()} or {@link #newKeySet(int)}), or viewed
* (using {@link #keySet(Object)} when only keys are of interest, and the
* mapped values are (perhaps transiently) not used or all take the
@@ -3860,6 +3858,23 @@ public class ConcurrentHashMapV8
}
/**
+ * Returns a non-null result from applying the given search
+ * function on each key, or null if none. Upon success,
+ * further element processing is suppressed and the results of
+ * any other parallel invocations of the search function are
+ * ignored.
+ *
+ * @param searchFunction a function returning a non-null
+ * result on success, else null
+ * @return a non-null result from applying the given search
+ * function on each key, or null if none
+ */
+ public U searchKeys(Fun super K, ? extends U> searchFunction) {
+ return ForkJoinTasks.searchKeys
+ (this, searchFunction).invoke();
+ }
+
+ /**
* Returns the result of accumulating all keys using the given
* reducer to combine values, or null if none.
*
@@ -4906,26 +4921,6 @@ public class ConcurrentHashMapV8
}
}
- // FJ methods
-
- /**
- * Propagates completion. Note that all reduce actions
- * bypass this method to combine while completing.
- */
- final void tryComplete() {
- BulkTask a = this, s = a;
- for (int c;;) {
- if ((c = a.pending) == 0) {
- if ((a = (s = a).parent) == null) {
- s.quietlyComplete();
- break;
- }
- }
- else if (U.compareAndSwapInt(a, PENDING, c, c - 1))
- break;
- }
- }
-
/**
* Forces root task to complete.
* @param ex if null, complete normally, else exceptionally
@@ -5004,6 +4999,50 @@ public class ConcurrentHashMapV8
}
}
+ /**
+ * Base class for non-reductive actions
+ */
+ @SuppressWarnings("serial") static abstract class BulkAction extends BulkTask {
+ BulkAction nextTask;
+ BulkAction(ConcurrentHashMapV8 map, BulkTask parent,
+ int batch, BulkAction nextTask) {
+ super(map, parent, batch);
+ this.nextTask = nextTask;
+ }
+
+ /**
+ * Try to complete task and upward parents. Upon hitting
+ * non-completed parent, if a non-FJ task, try to help out the
+ * computation.
+ */
+ final void tryComplete(BulkAction subtasks) {
+ BulkTask a = this, s = a;
+ for (int c;;) {
+ if ((c = a.pending) == 0) {
+ if ((a = (s = a).parent) == null) {
+ s.quietlyComplete();
+ break;
+ }
+ }
+ else if (a.casPending(c, c - 1)) {
+ if (subtasks != null && !inForkJoinPool()) {
+ while ((s = a.parent) != null)
+ a = s;
+ while (!a.isDone()) {
+ BulkAction next = subtasks.nextTask;
+ if (subtasks.tryUnfork())
+ subtasks.exec();
+ if ((subtasks = next) == null)
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ }
+
/*
* Task classes. Coded in a regular but ugly format/style to
* simplify checks that each variant differs in the right way from
@@ -5011,172 +5050,146 @@ public class ConcurrentHashMapV8
*/
@SuppressWarnings("serial") static final class ForEachKeyTask
- extends BulkTask {
+ extends BulkAction {
final Action action;
- ForEachKeyTask nextRight;
ForEachKeyTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachKeyTask nextRight,
+ ForEachKeyTask nextTask,
Action action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.action = action;
}
@SuppressWarnings("unchecked") public final boolean exec() {
final Action action = this.action;
if (action == null)
return abortOnNullFunction();
- ForEachKeyTask rights = null;
+ ForEachKeyTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachKeyTask
- (map, this, b >>>= 1, rights, action)).fork();
+ (subtasks = new ForEachKeyTask
+ (map, this, b >>>= 1, subtasks, action)).fork();
}
while (advance() != null)
action.apply((K)nextKey);
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachValueTask
- extends BulkTask {
- ForEachValueTask nextRight;
+ extends BulkAction {
final Action action;
ForEachValueTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachValueTask nextRight,
+ ForEachValueTask nextTask,
Action action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.action = action;
}
@SuppressWarnings("unchecked") public final boolean exec() {
final Action action = this.action;
if (action == null)
return abortOnNullFunction();
- ForEachValueTask rights = null;
+ ForEachValueTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachValueTask
- (map, this, b >>>= 1, rights, action)).fork();
+ (subtasks = new ForEachValueTask
+ (map, this, b >>>= 1, subtasks, action)).fork();
}
Object v;
while ((v = advance()) != null)
action.apply((V)v);
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachEntryTask
- extends BulkTask {
- ForEachEntryTask nextRight;
+ extends BulkAction {
final Action> action;
ForEachEntryTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachEntryTask nextRight,
+ ForEachEntryTask nextTask,
Action> action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.action = action;
}
@SuppressWarnings("unchecked") public final boolean exec() {
final Action> action = this.action;
if (action == null)
return abortOnNullFunction();
- ForEachEntryTask rights = null;
+ ForEachEntryTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachEntryTask
- (map, this, b >>>= 1, rights, action)).fork();
+ (subtasks = new ForEachEntryTask
+ (map, this, b >>>= 1, subtasks, action)).fork();
}
Object v;
while ((v = advance()) != null)
action.apply(entryFor((K)nextKey, (V)v));
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachMappingTask
- extends BulkTask {
- ForEachMappingTask nextRight;
+ extends BulkAction {
final BiAction action;
ForEachMappingTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachMappingTask nextRight,
+ ForEachMappingTask nextTask,
BiAction action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.action = action;
}
@SuppressWarnings("unchecked") public final boolean exec() {
final BiAction action = this.action;
if (action == null)
return abortOnNullFunction();
- ForEachMappingTask rights = null;
+ ForEachMappingTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachMappingTask
- (map, this, b >>>= 1, rights, action)).fork();
+ (subtasks = new ForEachMappingTask
+ (map, this, b >>>= 1, subtasks, action)).fork();
}
Object v;
while ((v = advance()) != null)
action.apply((K)nextKey, (V)v);
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachTransformedKeyTask
- extends BulkTask {
- ForEachTransformedKeyTask nextRight;
+ extends BulkAction {
final Fun super K, ? extends U> transformer;
final Action action;
ForEachTransformedKeyTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachTransformedKeyTask nextRight,
+ ForEachTransformedKeyTask nextTask,
Fun super K, ? extends U> transformer,
Action action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.transformer = transformer;
this.action = action;
@@ -5187,43 +5200,37 @@ public class ConcurrentHashMapV8
final Action action = this.action;
if (transformer == null || action == null)
return abortOnNullFunction();
- ForEachTransformedKeyTask rights = null;
+ ForEachTransformedKeyTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachTransformedKeyTask
- (map, this, b >>>= 1, rights, transformer, action)).fork();
+ (subtasks = new ForEachTransformedKeyTask
+ (map, this, b >>>= 1, subtasks, transformer, action)).fork();
}
U u;
while (advance() != null) {
if ((u = transformer.apply((K)nextKey)) != null)
action.apply(u);
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachTransformedValueTask
- extends BulkTask {
- ForEachTransformedValueTask nextRight;
+ extends BulkAction {
final Fun super V, ? extends U> transformer;
final Action action;
ForEachTransformedValueTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachTransformedValueTask nextRight,
+ ForEachTransformedValueTask nextTask,
Fun super V, ? extends U> transformer,
Action action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.transformer = transformer;
this.action = action;
@@ -5234,43 +5241,37 @@ public class ConcurrentHashMapV8
final Action action = this.action;
if (transformer == null || action == null)
return abortOnNullFunction();
- ForEachTransformedValueTask rights = null;
+ ForEachTransformedValueTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachTransformedValueTask
- (map, this, b >>>= 1, rights, transformer, action)).fork();
+ (subtasks = new ForEachTransformedValueTask
+ (map, this, b >>>= 1, subtasks, transformer, action)).fork();
}
Object v; U u;
while ((v = advance()) != null) {
if ((u = transformer.apply((V)v)) != null)
action.apply(u);
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachTransformedEntryTask
- extends BulkTask {
- ForEachTransformedEntryTask nextRight;
+ extends BulkAction {
final Fun, ? extends U> transformer;
final Action action;
ForEachTransformedEntryTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachTransformedEntryTask nextRight,
+ ForEachTransformedEntryTask nextTask,
Fun, ? extends U> transformer,
Action action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.transformer = transformer;
this.action = action;
@@ -5281,43 +5282,37 @@ public class ConcurrentHashMapV8
final Action action = this.action;
if (transformer == null || action == null)
return abortOnNullFunction();
- ForEachTransformedEntryTask rights = null;
+ ForEachTransformedEntryTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachTransformedEntryTask
- (map, this, b >>>= 1, rights, transformer, action)).fork();
+ (subtasks = new ForEachTransformedEntryTask
+ (map, this, b >>>= 1, subtasks, transformer, action)).fork();
}
Object v; U u;
while ((v = advance()) != null) {
if ((u = transformer.apply(entryFor((K)nextKey, (V)v))) != null)
action.apply(u);
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class ForEachTransformedMappingTask
- extends BulkTask {
- ForEachTransformedMappingTask nextRight;
+ extends BulkAction {
final BiFun super K, ? super V, ? extends U> transformer;
final Action action;
ForEachTransformedMappingTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- ForEachTransformedMappingTask nextRight,
+ ForEachTransformedMappingTask nextTask,
BiFun super K, ? super V, ? extends U> transformer,
Action action) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.transformer = transformer;
this.action = action;
@@ -5328,43 +5323,37 @@ public class ConcurrentHashMapV8
final Action action = this.action;
if (transformer == null || action == null)
return abortOnNullFunction();
- ForEachTransformedMappingTask rights = null;
+ ForEachTransformedMappingTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit) {
do {} while (!casPending(c = pending, c+1));
- (rights = new ForEachTransformedMappingTask
- (map, this, b >>>= 1, rights, transformer, action)).fork();
+ (subtasks = new ForEachTransformedMappingTask
+ (map, this, b >>>= 1, subtasks, transformer, action)).fork();
}
Object v; U u;
while ((v = advance()) != null) {
if ((u = transformer.apply((K)nextKey, (V)v)) != null)
action.apply(u);
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
}
@SuppressWarnings("serial") static final class SearchKeysTask
- extends BulkTask {
- SearchKeysTask nextRight;
+ extends BulkAction {
final Fun super K, ? extends U> searchFunction;
final AtomicReference result;
SearchKeysTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- SearchKeysTask nextRight,
+ SearchKeysTask nextTask,
Fun super K, ? extends U> searchFunction,
AtomicReference result) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.searchFunction = searchFunction; this.result = result;
}
@SuppressWarnings("unchecked") public final boolean exec() {
@@ -5373,13 +5362,13 @@ public class ConcurrentHashMapV8
this.searchFunction;
if (searchFunction == null || result == null)
return abortOnNullFunction();
- SearchKeysTask rights = null;
+ SearchKeysTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit && result.get() == null) {
do {} while (!casPending(c = pending, c+1));
- (rights = new SearchKeysTask
- (map, this, b >>>= 1, rights, searchFunction, result)).fork();
+ (subtasks = new SearchKeysTask
+ (map, this, b >>>= 1, subtasks, searchFunction, result)).fork();
}
U u;
while (result.get() == null && advance() != null) {
@@ -5389,31 +5378,25 @@ public class ConcurrentHashMapV8
break;
}
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && result.get() == null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
public final U getRawResult() { return result.get(); }
}
@SuppressWarnings("serial") static final class SearchValuesTask
- extends BulkTask {
- SearchValuesTask nextRight;
+ extends BulkAction {
final Fun super V, ? extends U> searchFunction;
final AtomicReference result;
SearchValuesTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- SearchValuesTask nextRight,
+ SearchValuesTask nextTask,
Fun super V, ? extends U> searchFunction,
AtomicReference result) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.searchFunction = searchFunction; this.result = result;
}
@SuppressWarnings("unchecked") public final boolean exec() {
@@ -5422,13 +5405,13 @@ public class ConcurrentHashMapV8
this.searchFunction;
if (searchFunction == null || result == null)
return abortOnNullFunction();
- SearchValuesTask rights = null;
+ SearchValuesTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit && result.get() == null) {
do {} while (!casPending(c = pending, c+1));
- (rights = new SearchValuesTask
- (map, this, b >>>= 1, rights, searchFunction, result)).fork();
+ (subtasks = new SearchValuesTask
+ (map, this, b >>>= 1, subtasks, searchFunction, result)).fork();
}
Object v; U u;
while (result.get() == null && (v = advance()) != null) {
@@ -5438,31 +5421,25 @@ public class ConcurrentHashMapV8
break;
}
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && result.get() == null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
public final U getRawResult() { return result.get(); }
}
@SuppressWarnings("serial") static final class SearchEntriesTask
- extends BulkTask {
- SearchEntriesTask nextRight;
+ extends BulkAction {
final Fun, ? extends U> searchFunction;
final AtomicReference result;
SearchEntriesTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- SearchEntriesTask nextRight,
+ SearchEntriesTask nextTask,
Fun, ? extends U> searchFunction,
AtomicReference result) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.searchFunction = searchFunction; this.result = result;
}
@SuppressWarnings("unchecked") public final boolean exec() {
@@ -5471,13 +5448,13 @@ public class ConcurrentHashMapV8
this.searchFunction;
if (searchFunction == null || result == null)
return abortOnNullFunction();
- SearchEntriesTask rights = null;
+ SearchEntriesTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit && result.get() == null) {
do {} while (!casPending(c = pending, c+1));
- (rights = new SearchEntriesTask
- (map, this, b >>>= 1, rights, searchFunction, result)).fork();
+ (subtasks = new SearchEntriesTask
+ (map, this, b >>>= 1, subtasks, searchFunction, result)).fork();
}
Object v; U u;
while (result.get() == null && (v = advance()) != null) {
@@ -5487,31 +5464,25 @@ public class ConcurrentHashMapV8
break;
}
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && result.get() == null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
public final U getRawResult() { return result.get(); }
}
@SuppressWarnings("serial") static final class SearchMappingsTask
- extends BulkTask {
- SearchMappingsTask nextRight;
+ extends BulkAction {
final BiFun super K, ? super V, ? extends U> searchFunction;
final AtomicReference result;
SearchMappingsTask
(ConcurrentHashMapV8 m, BulkTask p, int b,
- SearchMappingsTask nextRight,
+ SearchMappingsTask nextTask,
BiFun super K, ? super V, ? extends U> searchFunction,
AtomicReference result) {
- super(m, p, b);
- this.nextRight = nextRight;
+ super(m, p, b, nextTask);
this.searchFunction = searchFunction; this.result = result;
}
@SuppressWarnings("unchecked") public final boolean exec() {
@@ -5520,13 +5491,13 @@ public class ConcurrentHashMapV8
this.searchFunction;
if (searchFunction == null || result == null)
return abortOnNullFunction();
- SearchMappingsTask rights = null;
+ SearchMappingsTask subtasks = null;
try {
int b = batch(), c;
while (b > 1 && baseIndex != baseLimit && result.get() == null) {
do {} while (!casPending(c = pending, c+1));
- (rights = new SearchMappingsTask
- (map, this, b >>>= 1, rights, searchFunction, result)).fork();
+ (subtasks = new SearchMappingsTask
+ (map, this, b >>>= 1, subtasks, searchFunction, result)).fork();
}
Object v; U u;
while (result.get() == null && (v = advance()) != null) {
@@ -5536,14 +5507,10 @@ public class ConcurrentHashMapV8
break;
}
}
- tryComplete();
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- while (rights != null && result.get() == null && rights.tryUnfork()) {
- rights.exec();
- rights = rights.nextRight;
- }
+ tryComplete(subtasks);
return false;
}
public final U getRawResult() { return result.get(); }
@@ -5598,8 +5565,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (ReduceKeysTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ ReduceKeysTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final K getRawResult() { return result; }
@@ -5655,8 +5627,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (ReduceValuesTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ ReduceValuesTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final V getRawResult() { return result; }
@@ -5712,8 +5689,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (ReduceEntriesTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ ReduceEntriesTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Map.Entry getRawResult() { return result; }
@@ -5773,8 +5755,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceKeysTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceKeysTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final U getRawResult() { return result; }
@@ -5835,8 +5822,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceValuesTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceValuesTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final U getRawResult() { return result; }
@@ -5897,8 +5889,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceEntriesTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceEntriesTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final U getRawResult() { return result; }
@@ -5959,8 +5956,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceMappingsTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceMappingsTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final U getRawResult() { return result; }
@@ -6019,8 +6021,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceKeysToDoubleTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceKeysToDoubleTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Double getRawResult() { return result; }
@@ -6080,8 +6087,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceValuesToDoubleTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceValuesToDoubleTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Double getRawResult() { return result; }
@@ -6141,8 +6153,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceEntriesToDoubleTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceEntriesToDoubleTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Double getRawResult() { return result; }
@@ -6202,8 +6219,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceMappingsToDoubleTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceMappingsToDoubleTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Double getRawResult() { return result; }
@@ -6262,8 +6284,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceKeysToLongTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceKeysToLongTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Long getRawResult() { return result; }
@@ -6323,8 +6350,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceValuesToLongTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceValuesToLongTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Long getRawResult() { return result; }
@@ -6384,8 +6416,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceEntriesToLongTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceEntriesToLongTask s = rights;
+ if (s != null && !inForkJoinPool()) {
+ do {
+ if (s.tryUnfork())
+ s.exec();
+ } while ((s = s.nextRight) != null);
+ }
return false;
}
public final Long getRawResult() { return result; }
@@ -6445,8 +6482,13 @@ public class ConcurrentHashMapV8
} catch (Throwable ex) {
return tryCompleteComputation(ex);
}
- for (MapReduceMappingsToLongTask s = rights; s != null && s.tryUnfork(); s = s.nextRight)
- s.exec();
+ MapReduceMappingsToLongTask