5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166e; |
8 |
< |
import jsr166e.LongAdder; |
9 |
< |
import jsr166e.ForkJoinPool; |
10 |
< |
import jsr166e.ForkJoinTask; |
8 |
> |
|
9 |
|
import java.util.Comparator; |
10 |
|
import java.util.Arrays; |
11 |
|
import java.util.Map; |
82 |
|
* {@code hashCode()} is a sure way to slow down performance of any |
83 |
|
* hash table. |
84 |
|
* |
85 |
< |
* <p> A {@link Set} projection of a ConcurrentHashMap may be created |
85 |
> |
* <p> A {@link Set} projection of a ConcurrentHashMapV8 may be created |
86 |
|
* (using {@link #newKeySet()} or {@link #newKeySet(int)}), or viewed |
87 |
|
* (using {@link #keySet(Object)} when only keys are of interest, and the |
88 |
|
* mapped values are (perhaps transiently) not used or all take the |
103 |
|
* does <em>not</em> allow {@code null} to be used as a key or value. |
104 |
|
* |
105 |
|
* <p>ConcurrentHashMapV8s support parallel operations using the {@link |
106 |
< |
* ForkJoinPool#commonPool}. (Task that may be used in other contexts |
106 |
> |
* ForkJoinPool#commonPool}. (Tasks that may be used in other contexts |
107 |
|
* are available in class {@link ForkJoinTasks}). These operations are |
108 |
|
* designed to be safely, and often sensibly, applied even with maps |
109 |
|
* that are being concurrently updated by other threads; for example, |
193 |
|
* processing are common but not guaranteed. Operations involving |
194 |
|
* brief functions on small maps may execute more slowly than |
195 |
|
* sequential loops if the underlying work to parallelize the |
196 |
< |
* computation is more expensive than the computation |
197 |
< |
* itself. Similarly, parallelization may not lead to much actual |
198 |
< |
* parallelism if all processors are busy performing unrelated tasks. |
196 |
> |
* computation is more expensive than the computation itself. |
197 |
> |
* Similarly, parallelization may not lead to much actual parallelism |
198 |
> |
* if all processors are busy performing unrelated tasks. |
199 |
|
* |
200 |
|
* <p> All arguments to all task methods must be non-null. |
201 |
|
* |
3858 |
|
} |
3859 |
|
|
3860 |
|
/** |
3861 |
+ |
* Returns a non-null result from applying the given search |
3862 |
+ |
* function on each key, or null if none. Upon success, |
3863 |
+ |
* further element processing is suppressed and the results of |
3864 |
+ |
* any other parallel invocations of the search function are |
3865 |
+ |
* ignored. |
3866 |
+ |
* |
3867 |
+ |
* @param searchFunction a function returning a non-null |
3868 |
+ |
* result on success, else null |
3869 |
+ |
* @return a non-null result from applying the given search |
3870 |
+ |
* function on each key, or null if none |
3871 |
+ |
*/ |
3872 |
+ |
public <U> U searchKeys(Fun<? super K, ? extends U> searchFunction) { |
3873 |
+ |
return ForkJoinTasks.searchKeys |
3874 |
+ |
(this, searchFunction).invoke(); |
3875 |
+ |
} |
3876 |
+ |
|
3877 |
+ |
/** |
3878 |
|
* Returns the result of accumulating all keys using the given |
3879 |
|
* reducer to combine values, or null if none. |
3880 |
|
* |
4921 |
|
} |
4922 |
|
} |
4923 |
|
|
4909 |
– |
// FJ methods |
4910 |
– |
|
4911 |
– |
/** |
4912 |
– |
* Propagates completion. Note that all reduce actions |
4913 |
– |
* bypass this method to combine while completing. |
4914 |
– |
*/ |
4915 |
– |
final void tryComplete() { |
4916 |
– |
BulkTask<K,V,?> a = this, s = a; |
4917 |
– |
for (int c;;) { |
4918 |
– |
if ((c = a.pending) == 0) { |
4919 |
– |
if ((a = (s = a).parent) == null) { |
4920 |
– |
s.quietlyComplete(); |
4921 |
– |
break; |
4922 |
– |
} |
4923 |
– |
} |
4924 |
– |
else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) |
4925 |
– |
break; |
4926 |
– |
} |
4927 |
– |
} |
4928 |
– |
|
4924 |
|
/** |
4925 |
|
* Forces root task to complete. |
4926 |
|
* @param ex if null, complete normally, else exceptionally |
4968 |
|
baseLimit = baseSize = t.length; |
4969 |
|
if (t != null) { |
4970 |
|
long n = m.counter.sum(); |
4971 |
< |
int par = (pool = getPool()) == null? |
4971 |
> |
int par = ((pool = getPool()) == null) ? |
4972 |
|
ForkJoinPool.getCommonPoolParallelism() : |
4973 |
|
pool.getParallelism(); |
4974 |
|
int sp = par << 3; // slack of 8 |
4999 |
|
} |
5000 |
|
} |
5001 |
|
|
5002 |
+ |
/** |
5003 |
+ |
* Base class for non-reductive actions |
5004 |
+ |
*/ |
5005 |
+ |
@SuppressWarnings("serial") static abstract class BulkAction<K,V,R> extends BulkTask<K,V,R> { |
5006 |
+ |
BulkAction<K,V,?> nextTask; |
5007 |
+ |
BulkAction(ConcurrentHashMapV8<K,V> map, BulkTask<K,V,?> parent, |
5008 |
+ |
int batch, BulkAction<K,V,?> nextTask) { |
5009 |
+ |
super(map, parent, batch); |
5010 |
+ |
this.nextTask = nextTask; |
5011 |
+ |
} |
5012 |
+ |
|
5013 |
+ |
/** |
5014 |
+ |
* Try to complete task and upward parents. Upon hitting |
5015 |
+ |
* non-completed parent, if a non-FJ task, try to help out the |
5016 |
+ |
* computation. |
5017 |
+ |
*/ |
5018 |
+ |
final void tryComplete(BulkAction<K,V,?> subtasks) { |
5019 |
+ |
BulkTask<K,V,?> a = this, s = a; |
5020 |
+ |
for (int c;;) { |
5021 |
+ |
if ((c = a.pending) == 0) { |
5022 |
+ |
if ((a = (s = a).parent) == null) { |
5023 |
+ |
s.quietlyComplete(); |
5024 |
+ |
break; |
5025 |
+ |
} |
5026 |
+ |
} |
5027 |
+ |
else if (a.casPending(c, c - 1)) { |
5028 |
+ |
if (subtasks != null && !inForkJoinPool()) { |
5029 |
+ |
while ((s = a.parent) != null) |
5030 |
+ |
a = s; |
5031 |
+ |
while (!a.isDone()) { |
5032 |
+ |
BulkAction<K,V,?> next = subtasks.nextTask; |
5033 |
+ |
if (subtasks.tryUnfork()) |
5034 |
+ |
subtasks.exec(); |
5035 |
+ |
if ((subtasks = next) == null) |
5036 |
+ |
break; |
5037 |
+ |
} |
5038 |
+ |
} |
5039 |
+ |
break; |
5040 |
+ |
} |
5041 |
+ |
} |
5042 |
+ |
} |
5043 |
+ |
|
5044 |
+ |
} |
5045 |
+ |
|
5046 |
|
/* |
5047 |
|
* Task classes. Coded in a regular but ugly format/style to |
5048 |
|
* simplify checks that each variant differs in the right way from |
5050 |
|
*/ |
5051 |
|
|
5052 |
|
@SuppressWarnings("serial") static final class ForEachKeyTask<K,V> |
5053 |
< |
extends BulkTask<K,V,Void> { |
5053 |
> |
extends BulkAction<K,V,Void> { |
5054 |
|
final Action<K> action; |
5016 |
– |
ForEachKeyTask<K,V> nextRight; |
5055 |
|
ForEachKeyTask |
5056 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5057 |
< |
ForEachKeyTask<K,V> nextRight, |
5057 |
> |
ForEachKeyTask<K,V> nextTask, |
5058 |
|
Action<K> action) { |
5059 |
< |
super(m, p, b); |
5022 |
< |
this.nextRight = nextRight; |
5059 |
> |
super(m, p, b, nextTask); |
5060 |
|
this.action = action; |
5061 |
|
} |
5062 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5063 |
|
final Action<K> action = this.action; |
5064 |
|
if (action == null) |
5065 |
|
return abortOnNullFunction(); |
5066 |
< |
ForEachKeyTask<K,V> rights = null; |
5066 |
> |
ForEachKeyTask<K,V> subtasks = null; |
5067 |
|
try { |
5068 |
|
int b = batch(), c; |
5069 |
|
while (b > 1 && baseIndex != baseLimit) { |
5070 |
|
do {} while (!casPending(c = pending, c+1)); |
5071 |
< |
(rights = new ForEachKeyTask<K,V> |
5072 |
< |
(map, this, b >>>= 1, rights, action)).fork(); |
5071 |
> |
(subtasks = new ForEachKeyTask<K,V> |
5072 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5073 |
|
} |
5074 |
|
while (advance() != null) |
5075 |
|
action.apply((K)nextKey); |
5039 |
– |
tryComplete(); |
5076 |
|
} catch (Throwable ex) { |
5077 |
|
return tryCompleteComputation(ex); |
5078 |
|
} |
5079 |
< |
while (rights != null && rights.tryUnfork()) { |
5044 |
< |
rights.exec(); |
5045 |
< |
rights = rights.nextRight; |
5046 |
< |
} |
5079 |
> |
tryComplete(subtasks); |
5080 |
|
return false; |
5081 |
|
} |
5082 |
|
} |
5083 |
|
|
5084 |
|
@SuppressWarnings("serial") static final class ForEachValueTask<K,V> |
5085 |
< |
extends BulkTask<K,V,Void> { |
5053 |
< |
ForEachValueTask<K,V> nextRight; |
5085 |
> |
extends BulkAction<K,V,Void> { |
5086 |
|
final Action<V> action; |
5087 |
|
ForEachValueTask |
5088 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5089 |
< |
ForEachValueTask<K,V> nextRight, |
5089 |
> |
ForEachValueTask<K,V> nextTask, |
5090 |
|
Action<V> action) { |
5091 |
< |
super(m, p, b); |
5060 |
< |
this.nextRight = nextRight; |
5091 |
> |
super(m, p, b, nextTask); |
5092 |
|
this.action = action; |
5093 |
|
} |
5094 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5095 |
|
final Action<V> action = this.action; |
5096 |
|
if (action == null) |
5097 |
|
return abortOnNullFunction(); |
5098 |
< |
ForEachValueTask<K,V> rights = null; |
5098 |
> |
ForEachValueTask<K,V> subtasks = null; |
5099 |
|
try { |
5100 |
|
int b = batch(), c; |
5101 |
|
while (b > 1 && baseIndex != baseLimit) { |
5102 |
|
do {} while (!casPending(c = pending, c+1)); |
5103 |
< |
(rights = new ForEachValueTask<K,V> |
5104 |
< |
(map, this, b >>>= 1, rights, action)).fork(); |
5103 |
> |
(subtasks = new ForEachValueTask<K,V> |
5104 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5105 |
|
} |
5106 |
|
Object v; |
5107 |
|
while ((v = advance()) != null) |
5108 |
|
action.apply((V)v); |
5078 |
– |
tryComplete(); |
5109 |
|
} catch (Throwable ex) { |
5110 |
|
return tryCompleteComputation(ex); |
5111 |
|
} |
5112 |
< |
while (rights != null && rights.tryUnfork()) { |
5083 |
< |
rights.exec(); |
5084 |
< |
rights = rights.nextRight; |
5085 |
< |
} |
5112 |
> |
tryComplete(subtasks); |
5113 |
|
return false; |
5114 |
|
} |
5115 |
|
} |
5116 |
|
|
5117 |
|
@SuppressWarnings("serial") static final class ForEachEntryTask<K,V> |
5118 |
< |
extends BulkTask<K,V,Void> { |
5092 |
< |
ForEachEntryTask<K,V> nextRight; |
5118 |
> |
extends BulkAction<K,V,Void> { |
5119 |
|
final Action<Entry<K,V>> action; |
5120 |
|
ForEachEntryTask |
5121 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5122 |
< |
ForEachEntryTask<K,V> nextRight, |
5122 |
> |
ForEachEntryTask<K,V> nextTask, |
5123 |
|
Action<Entry<K,V>> action) { |
5124 |
< |
super(m, p, b); |
5099 |
< |
this.nextRight = nextRight; |
5124 |
> |
super(m, p, b, nextTask); |
5125 |
|
this.action = action; |
5126 |
|
} |
5127 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5128 |
|
final Action<Entry<K,V>> action = this.action; |
5129 |
|
if (action == null) |
5130 |
|
return abortOnNullFunction(); |
5131 |
< |
ForEachEntryTask<K,V> rights = null; |
5131 |
> |
ForEachEntryTask<K,V> subtasks = null; |
5132 |
|
try { |
5133 |
|
int b = batch(), c; |
5134 |
|
while (b > 1 && baseIndex != baseLimit) { |
5135 |
|
do {} while (!casPending(c = pending, c+1)); |
5136 |
< |
(rights = new ForEachEntryTask<K,V> |
5137 |
< |
(map, this, b >>>= 1, rights, action)).fork(); |
5136 |
> |
(subtasks = new ForEachEntryTask<K,V> |
5137 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5138 |
|
} |
5139 |
|
Object v; |
5140 |
|
while ((v = advance()) != null) |
5141 |
|
action.apply(entryFor((K)nextKey, (V)v)); |
5117 |
– |
tryComplete(); |
5142 |
|
} catch (Throwable ex) { |
5143 |
|
return tryCompleteComputation(ex); |
5144 |
|
} |
5145 |
< |
while (rights != null && rights.tryUnfork()) { |
5122 |
< |
rights.exec(); |
5123 |
< |
rights = rights.nextRight; |
5124 |
< |
} |
5145 |
> |
tryComplete(subtasks); |
5146 |
|
return false; |
5147 |
|
} |
5148 |
|
} |
5149 |
|
|
5150 |
|
@SuppressWarnings("serial") static final class ForEachMappingTask<K,V> |
5151 |
< |
extends BulkTask<K,V,Void> { |
5131 |
< |
ForEachMappingTask<K,V> nextRight; |
5151 |
> |
extends BulkAction<K,V,Void> { |
5152 |
|
final BiAction<K,V> action; |
5153 |
|
ForEachMappingTask |
5154 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5155 |
< |
ForEachMappingTask<K,V> nextRight, |
5155 |
> |
ForEachMappingTask<K,V> nextTask, |
5156 |
|
BiAction<K,V> action) { |
5157 |
< |
super(m, p, b); |
5138 |
< |
this.nextRight = nextRight; |
5157 |
> |
super(m, p, b, nextTask); |
5158 |
|
this.action = action; |
5159 |
|
} |
5160 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5161 |
|
final BiAction<K,V> action = this.action; |
5162 |
|
if (action == null) |
5163 |
|
return abortOnNullFunction(); |
5164 |
< |
ForEachMappingTask<K,V> rights = null; |
5164 |
> |
ForEachMappingTask<K,V> subtasks = null; |
5165 |
|
try { |
5166 |
|
int b = batch(), c; |
5167 |
|
while (b > 1 && baseIndex != baseLimit) { |
5168 |
|
do {} while (!casPending(c = pending, c+1)); |
5169 |
< |
(rights = new ForEachMappingTask<K,V> |
5170 |
< |
(map, this, b >>>= 1, rights, action)).fork(); |
5169 |
> |
(subtasks = new ForEachMappingTask<K,V> |
5170 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5171 |
|
} |
5172 |
|
Object v; |
5173 |
|
while ((v = advance()) != null) |
5174 |
|
action.apply((K)nextKey, (V)v); |
5156 |
– |
tryComplete(); |
5175 |
|
} catch (Throwable ex) { |
5176 |
|
return tryCompleteComputation(ex); |
5177 |
|
} |
5178 |
< |
while (rights != null && rights.tryUnfork()) { |
5161 |
< |
rights.exec(); |
5162 |
< |
rights = rights.nextRight; |
5163 |
< |
} |
5178 |
> |
tryComplete(subtasks); |
5179 |
|
return false; |
5180 |
|
} |
5181 |
|
} |
5182 |
|
|
5183 |
|
@SuppressWarnings("serial") static final class ForEachTransformedKeyTask<K,V,U> |
5184 |
< |
extends BulkTask<K,V,Void> { |
5170 |
< |
ForEachTransformedKeyTask<K,V,U> nextRight; |
5184 |
> |
extends BulkAction<K,V,Void> { |
5185 |
|
final Fun<? super K, ? extends U> transformer; |
5186 |
|
final Action<U> action; |
5187 |
|
ForEachTransformedKeyTask |
5188 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5189 |
< |
ForEachTransformedKeyTask<K,V,U> nextRight, |
5189 |
> |
ForEachTransformedKeyTask<K,V,U> nextTask, |
5190 |
|
Fun<? super K, ? extends U> transformer, |
5191 |
|
Action<U> action) { |
5192 |
< |
super(m, p, b); |
5179 |
< |
this.nextRight = nextRight; |
5192 |
> |
super(m, p, b, nextTask); |
5193 |
|
this.transformer = transformer; |
5194 |
|
this.action = action; |
5195 |
|
|
5200 |
|
final Action<U> action = this.action; |
5201 |
|
if (transformer == null || action == null) |
5202 |
|
return abortOnNullFunction(); |
5203 |
< |
ForEachTransformedKeyTask<K,V,U> rights = null; |
5203 |
> |
ForEachTransformedKeyTask<K,V,U> subtasks = null; |
5204 |
|
try { |
5205 |
|
int b = batch(), c; |
5206 |
|
while (b > 1 && baseIndex != baseLimit) { |
5207 |
|
do {} while (!casPending(c = pending, c+1)); |
5208 |
< |
(rights = new ForEachTransformedKeyTask<K,V,U> |
5209 |
< |
(map, this, b >>>= 1, rights, transformer, action)).fork(); |
5208 |
> |
(subtasks = new ForEachTransformedKeyTask<K,V,U> |
5209 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5210 |
|
} |
5211 |
|
U u; |
5212 |
|
while (advance() != null) { |
5213 |
|
if ((u = transformer.apply((K)nextKey)) != null) |
5214 |
|
action.apply(u); |
5215 |
|
} |
5203 |
– |
tryComplete(); |
5216 |
|
} catch (Throwable ex) { |
5217 |
|
return tryCompleteComputation(ex); |
5218 |
|
} |
5219 |
< |
while (rights != null && rights.tryUnfork()) { |
5208 |
< |
rights.exec(); |
5209 |
< |
rights = rights.nextRight; |
5210 |
< |
} |
5219 |
> |
tryComplete(subtasks); |
5220 |
|
return false; |
5221 |
|
} |
5222 |
|
} |
5223 |
|
|
5224 |
|
@SuppressWarnings("serial") static final class ForEachTransformedValueTask<K,V,U> |
5225 |
< |
extends BulkTask<K,V,Void> { |
5217 |
< |
ForEachTransformedValueTask<K,V,U> nextRight; |
5225 |
> |
extends BulkAction<K,V,Void> { |
5226 |
|
final Fun<? super V, ? extends U> transformer; |
5227 |
|
final Action<U> action; |
5228 |
|
ForEachTransformedValueTask |
5229 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5230 |
< |
ForEachTransformedValueTask<K,V,U> nextRight, |
5230 |
> |
ForEachTransformedValueTask<K,V,U> nextTask, |
5231 |
|
Fun<? super V, ? extends U> transformer, |
5232 |
|
Action<U> action) { |
5233 |
< |
super(m, p, b); |
5226 |
< |
this.nextRight = nextRight; |
5233 |
> |
super(m, p, b, nextTask); |
5234 |
|
this.transformer = transformer; |
5235 |
|
this.action = action; |
5236 |
|
|
5241 |
|
final Action<U> action = this.action; |
5242 |
|
if (transformer == null || action == null) |
5243 |
|
return abortOnNullFunction(); |
5244 |
< |
ForEachTransformedValueTask<K,V,U> rights = null; |
5244 |
> |
ForEachTransformedValueTask<K,V,U> subtasks = null; |
5245 |
|
try { |
5246 |
|
int b = batch(), c; |
5247 |
|
while (b > 1 && baseIndex != baseLimit) { |
5248 |
|
do {} while (!casPending(c = pending, c+1)); |
5249 |
< |
(rights = new ForEachTransformedValueTask<K,V,U> |
5250 |
< |
(map, this, b >>>= 1, rights, transformer, action)).fork(); |
5249 |
> |
(subtasks = new ForEachTransformedValueTask<K,V,U> |
5250 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5251 |
|
} |
5252 |
|
Object v; U u; |
5253 |
|
while ((v = advance()) != null) { |
5254 |
|
if ((u = transformer.apply((V)v)) != null) |
5255 |
|
action.apply(u); |
5256 |
|
} |
5250 |
– |
tryComplete(); |
5257 |
|
} catch (Throwable ex) { |
5258 |
|
return tryCompleteComputation(ex); |
5259 |
|
} |
5260 |
< |
while (rights != null && rights.tryUnfork()) { |
5255 |
< |
rights.exec(); |
5256 |
< |
rights = rights.nextRight; |
5257 |
< |
} |
5260 |
> |
tryComplete(subtasks); |
5261 |
|
return false; |
5262 |
|
} |
5263 |
|
} |
5264 |
|
|
5265 |
|
@SuppressWarnings("serial") static final class ForEachTransformedEntryTask<K,V,U> |
5266 |
< |
extends BulkTask<K,V,Void> { |
5264 |
< |
ForEachTransformedEntryTask<K,V,U> nextRight; |
5266 |
> |
extends BulkAction<K,V,Void> { |
5267 |
|
final Fun<Map.Entry<K,V>, ? extends U> transformer; |
5268 |
|
final Action<U> action; |
5269 |
|
ForEachTransformedEntryTask |
5270 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5271 |
< |
ForEachTransformedEntryTask<K,V,U> nextRight, |
5271 |
> |
ForEachTransformedEntryTask<K,V,U> nextTask, |
5272 |
|
Fun<Map.Entry<K,V>, ? extends U> transformer, |
5273 |
|
Action<U> action) { |
5274 |
< |
super(m, p, b); |
5273 |
< |
this.nextRight = nextRight; |
5274 |
> |
super(m, p, b, nextTask); |
5275 |
|
this.transformer = transformer; |
5276 |
|
this.action = action; |
5277 |
|
|
5282 |
|
final Action<U> action = this.action; |
5283 |
|
if (transformer == null || action == null) |
5284 |
|
return abortOnNullFunction(); |
5285 |
< |
ForEachTransformedEntryTask<K,V,U> rights = null; |
5285 |
> |
ForEachTransformedEntryTask<K,V,U> subtasks = null; |
5286 |
|
try { |
5287 |
|
int b = batch(), c; |
5288 |
|
while (b > 1 && baseIndex != baseLimit) { |
5289 |
|
do {} while (!casPending(c = pending, c+1)); |
5290 |
< |
(rights = new ForEachTransformedEntryTask<K,V,U> |
5291 |
< |
(map, this, b >>>= 1, rights, transformer, action)).fork(); |
5290 |
> |
(subtasks = new ForEachTransformedEntryTask<K,V,U> |
5291 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5292 |
|
} |
5293 |
|
Object v; U u; |
5294 |
|
while ((v = advance()) != null) { |
5295 |
|
if ((u = transformer.apply(entryFor((K)nextKey, (V)v))) != null) |
5296 |
|
action.apply(u); |
5297 |
|
} |
5297 |
– |
tryComplete(); |
5298 |
|
} catch (Throwable ex) { |
5299 |
|
return tryCompleteComputation(ex); |
5300 |
|
} |
5301 |
< |
while (rights != null && rights.tryUnfork()) { |
5302 |
< |
rights.exec(); |
5303 |
< |
rights = rights.nextRight; |
5304 |
< |
} |
5301 |
> |
tryComplete(subtasks); |
5302 |
|
return false; |
5303 |
|
} |
5304 |
|
} |
5305 |
|
|
5306 |
|
@SuppressWarnings("serial") static final class ForEachTransformedMappingTask<K,V,U> |
5307 |
< |
extends BulkTask<K,V,Void> { |
5311 |
< |
ForEachTransformedMappingTask<K,V,U> nextRight; |
5307 |
> |
extends BulkAction<K,V,Void> { |
5308 |
|
final BiFun<? super K, ? super V, ? extends U> transformer; |
5309 |
|
final Action<U> action; |
5310 |
|
ForEachTransformedMappingTask |
5311 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5312 |
< |
ForEachTransformedMappingTask<K,V,U> nextRight, |
5312 |
> |
ForEachTransformedMappingTask<K,V,U> nextTask, |
5313 |
|
BiFun<? super K, ? super V, ? extends U> transformer, |
5314 |
|
Action<U> action) { |
5315 |
< |
super(m, p, b); |
5320 |
< |
this.nextRight = nextRight; |
5315 |
> |
super(m, p, b, nextTask); |
5316 |
|
this.transformer = transformer; |
5317 |
|
this.action = action; |
5318 |
|
|
5323 |
|
final Action<U> action = this.action; |
5324 |
|
if (transformer == null || action == null) |
5325 |
|
return abortOnNullFunction(); |
5326 |
< |
ForEachTransformedMappingTask<K,V,U> rights = null; |
5326 |
> |
ForEachTransformedMappingTask<K,V,U> subtasks = null; |
5327 |
|
try { |
5328 |
|
int b = batch(), c; |
5329 |
|
while (b > 1 && baseIndex != baseLimit) { |
5330 |
|
do {} while (!casPending(c = pending, c+1)); |
5331 |
< |
(rights = new ForEachTransformedMappingTask<K,V,U> |
5332 |
< |
(map, this, b >>>= 1, rights, transformer, action)).fork(); |
5331 |
> |
(subtasks = new ForEachTransformedMappingTask<K,V,U> |
5332 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5333 |
|
} |
5334 |
|
Object v; U u; |
5335 |
|
while ((v = advance()) != null) { |
5336 |
|
if ((u = transformer.apply((K)nextKey, (V)v)) != null) |
5337 |
|
action.apply(u); |
5338 |
|
} |
5344 |
– |
tryComplete(); |
5339 |
|
} catch (Throwable ex) { |
5340 |
|
return tryCompleteComputation(ex); |
5341 |
|
} |
5342 |
< |
while (rights != null && rights.tryUnfork()) { |
5349 |
< |
rights.exec(); |
5350 |
< |
rights = rights.nextRight; |
5351 |
< |
} |
5342 |
> |
tryComplete(subtasks); |
5343 |
|
return false; |
5344 |
|
} |
5345 |
|
} |
5346 |
|
|
5347 |
|
@SuppressWarnings("serial") static final class SearchKeysTask<K,V,U> |
5348 |
< |
extends BulkTask<K,V,U> { |
5358 |
< |
SearchKeysTask<K,V,U> nextRight; |
5348 |
> |
extends BulkAction<K,V,U> { |
5349 |
|
final Fun<? super K, ? extends U> searchFunction; |
5350 |
|
final AtomicReference<U> result; |
5351 |
|
SearchKeysTask |
5352 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5353 |
< |
SearchKeysTask<K,V,U> nextRight, |
5353 |
> |
SearchKeysTask<K,V,U> nextTask, |
5354 |
|
Fun<? super K, ? extends U> searchFunction, |
5355 |
|
AtomicReference<U> result) { |
5356 |
< |
super(m, p, b); |
5367 |
< |
this.nextRight = nextRight; |
5356 |
> |
super(m, p, b, nextTask); |
5357 |
|
this.searchFunction = searchFunction; this.result = result; |
5358 |
|
} |
5359 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5362 |
|
this.searchFunction; |
5363 |
|
if (searchFunction == null || result == null) |
5364 |
|
return abortOnNullFunction(); |
5365 |
< |
SearchKeysTask<K,V,U> rights = null; |
5365 |
> |
SearchKeysTask<K,V,U> subtasks = null; |
5366 |
|
try { |
5367 |
|
int b = batch(), c; |
5368 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5369 |
|
do {} while (!casPending(c = pending, c+1)); |
5370 |
< |
(rights = new SearchKeysTask<K,V,U> |
5371 |
< |
(map, this, b >>>= 1, rights, searchFunction, result)).fork(); |
5370 |
> |
(subtasks = new SearchKeysTask<K,V,U> |
5371 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5372 |
|
} |
5373 |
|
U u; |
5374 |
|
while (result.get() == null && advance() != null) { |
5378 |
|
break; |
5379 |
|
} |
5380 |
|
} |
5392 |
– |
tryComplete(); |
5381 |
|
} catch (Throwable ex) { |
5382 |
|
return tryCompleteComputation(ex); |
5383 |
|
} |
5384 |
< |
while (rights != null && result.get() == null && rights.tryUnfork()) { |
5397 |
< |
rights.exec(); |
5398 |
< |
rights = rights.nextRight; |
5399 |
< |
} |
5384 |
> |
tryComplete(subtasks); |
5385 |
|
return false; |
5386 |
|
} |
5387 |
|
public final U getRawResult() { return result.get(); } |
5388 |
|
} |
5389 |
|
|
5390 |
|
@SuppressWarnings("serial") static final class SearchValuesTask<K,V,U> |
5391 |
< |
extends BulkTask<K,V,U> { |
5407 |
< |
SearchValuesTask<K,V,U> nextRight; |
5391 |
> |
extends BulkAction<K,V,U> { |
5392 |
|
final Fun<? super V, ? extends U> searchFunction; |
5393 |
|
final AtomicReference<U> result; |
5394 |
|
SearchValuesTask |
5395 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5396 |
< |
SearchValuesTask<K,V,U> nextRight, |
5396 |
> |
SearchValuesTask<K,V,U> nextTask, |
5397 |
|
Fun<? super V, ? extends U> searchFunction, |
5398 |
|
AtomicReference<U> result) { |
5399 |
< |
super(m, p, b); |
5416 |
< |
this.nextRight = nextRight; |
5399 |
> |
super(m, p, b, nextTask); |
5400 |
|
this.searchFunction = searchFunction; this.result = result; |
5401 |
|
} |
5402 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5405 |
|
this.searchFunction; |
5406 |
|
if (searchFunction == null || result == null) |
5407 |
|
return abortOnNullFunction(); |
5408 |
< |
SearchValuesTask<K,V,U> rights = null; |
5408 |
> |
SearchValuesTask<K,V,U> subtasks = null; |
5409 |
|
try { |
5410 |
|
int b = batch(), c; |
5411 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5412 |
|
do {} while (!casPending(c = pending, c+1)); |
5413 |
< |
(rights = new SearchValuesTask<K,V,U> |
5414 |
< |
(map, this, b >>>= 1, rights, searchFunction, result)).fork(); |
5413 |
> |
(subtasks = new SearchValuesTask<K,V,U> |
5414 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5415 |
|
} |
5416 |
|
Object v; U u; |
5417 |
|
while (result.get() == null && (v = advance()) != null) { |
5421 |
|
break; |
5422 |
|
} |
5423 |
|
} |
5441 |
– |
tryComplete(); |
5424 |
|
} catch (Throwable ex) { |
5425 |
|
return tryCompleteComputation(ex); |
5426 |
|
} |
5427 |
< |
while (rights != null && result.get() == null && rights.tryUnfork()) { |
5446 |
< |
rights.exec(); |
5447 |
< |
rights = rights.nextRight; |
5448 |
< |
} |
5427 |
> |
tryComplete(subtasks); |
5428 |
|
return false; |
5429 |
|
} |
5430 |
|
public final U getRawResult() { return result.get(); } |
5431 |
|
} |
5432 |
|
|
5433 |
|
@SuppressWarnings("serial") static final class SearchEntriesTask<K,V,U> |
5434 |
< |
extends BulkTask<K,V,U> { |
5456 |
< |
SearchEntriesTask<K,V,U> nextRight; |
5434 |
> |
extends BulkAction<K,V,U> { |
5435 |
|
final Fun<Entry<K,V>, ? extends U> searchFunction; |
5436 |
|
final AtomicReference<U> result; |
5437 |
|
SearchEntriesTask |
5438 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5439 |
< |
SearchEntriesTask<K,V,U> nextRight, |
5439 |
> |
SearchEntriesTask<K,V,U> nextTask, |
5440 |
|
Fun<Entry<K,V>, ? extends U> searchFunction, |
5441 |
|
AtomicReference<U> result) { |
5442 |
< |
super(m, p, b); |
5465 |
< |
this.nextRight = nextRight; |
5442 |
> |
super(m, p, b, nextTask); |
5443 |
|
this.searchFunction = searchFunction; this.result = result; |
5444 |
|
} |
5445 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5448 |
|
this.searchFunction; |
5449 |
|
if (searchFunction == null || result == null) |
5450 |
|
return abortOnNullFunction(); |
5451 |
< |
SearchEntriesTask<K,V,U> rights = null; |
5451 |
> |
SearchEntriesTask<K,V,U> subtasks = null; |
5452 |
|
try { |
5453 |
|
int b = batch(), c; |
5454 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5455 |
|
do {} while (!casPending(c = pending, c+1)); |
5456 |
< |
(rights = new SearchEntriesTask<K,V,U> |
5457 |
< |
(map, this, b >>>= 1, rights, searchFunction, result)).fork(); |
5456 |
> |
(subtasks = new SearchEntriesTask<K,V,U> |
5457 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5458 |
|
} |
5459 |
|
Object v; U u; |
5460 |
|
while (result.get() == null && (v = advance()) != null) { |
5464 |
|
break; |
5465 |
|
} |
5466 |
|
} |
5490 |
– |
tryComplete(); |
5467 |
|
} catch (Throwable ex) { |
5468 |
|
return tryCompleteComputation(ex); |
5469 |
|
} |
5470 |
< |
while (rights != null && result.get() == null && rights.tryUnfork()) { |
5495 |
< |
rights.exec(); |
5496 |
< |
rights = rights.nextRight; |
5497 |
< |
} |
5470 |
> |
tryComplete(subtasks); |
5471 |
|
return false; |
5472 |
|
} |
5473 |
|
public final U getRawResult() { return result.get(); } |
5474 |
|
} |
5475 |
|
|
5476 |
|
@SuppressWarnings("serial") static final class SearchMappingsTask<K,V,U> |
5477 |
< |
extends BulkTask<K,V,U> { |
5505 |
< |
SearchMappingsTask<K,V,U> nextRight; |
5477 |
> |
extends BulkAction<K,V,U> { |
5478 |
|
final BiFun<? super K, ? super V, ? extends U> searchFunction; |
5479 |
|
final AtomicReference<U> result; |
5480 |
|
SearchMappingsTask |
5481 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5482 |
< |
SearchMappingsTask<K,V,U> nextRight, |
5482 |
> |
SearchMappingsTask<K,V,U> nextTask, |
5483 |
|
BiFun<? super K, ? super V, ? extends U> searchFunction, |
5484 |
|
AtomicReference<U> result) { |
5485 |
< |
super(m, p, b); |
5514 |
< |
this.nextRight = nextRight; |
5485 |
> |
super(m, p, b, nextTask); |
5486 |
|
this.searchFunction = searchFunction; this.result = result; |
5487 |
|
} |
5488 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5491 |
|
this.searchFunction; |
5492 |
|
if (searchFunction == null || result == null) |
5493 |
|
return abortOnNullFunction(); |
5494 |
< |
SearchMappingsTask<K,V,U> rights = null; |
5494 |
> |
SearchMappingsTask<K,V,U> subtasks = null; |
5495 |
|
try { |
5496 |
|
int b = batch(), c; |
5497 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5498 |
|
do {} while (!casPending(c = pending, c+1)); |
5499 |
< |
(rights = new SearchMappingsTask<K,V,U> |
5500 |
< |
(map, this, b >>>= 1, rights, searchFunction, result)).fork(); |
5499 |
> |
(subtasks = new SearchMappingsTask<K,V,U> |
5500 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5501 |
|
} |
5502 |
|
Object v; U u; |
5503 |
|
while (result.get() == null && (v = advance()) != null) { |
5507 |
|
break; |
5508 |
|
} |
5509 |
|
} |
5539 |
– |
tryComplete(); |
5510 |
|
} catch (Throwable ex) { |
5511 |
|
return tryCompleteComputation(ex); |
5512 |
|
} |
5513 |
< |
while (rights != null && result.get() == null && rights.tryUnfork()) { |
5544 |
< |
rights.exec(); |
5545 |
< |
rights = rights.nextRight; |
5546 |
< |
} |
5513 |
> |
tryComplete(subtasks); |
5514 |
|
return false; |
5515 |
|
} |
5516 |
|
public final U getRawResult() { return result.get(); } |
5565 |
|
} catch (Throwable ex) { |
5566 |
|
return tryCompleteComputation(ex); |
5567 |
|
} |
5568 |
< |
for (ReduceKeysTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5569 |
< |
s.exec(); |
5568 |
> |
ReduceKeysTask<K,V> s = rights; |
5569 |
> |
if (s != null && !inForkJoinPool()) { |
5570 |
> |
do { |
5571 |
> |
if (s.tryUnfork()) |
5572 |
> |
s.exec(); |
5573 |
> |
} while ((s = s.nextRight) != null); |
5574 |
> |
} |
5575 |
|
return false; |
5576 |
|
} |
5577 |
|
public final K getRawResult() { return result; } |
5627 |
|
} catch (Throwable ex) { |
5628 |
|
return tryCompleteComputation(ex); |
5629 |
|
} |
5630 |
< |
for (ReduceValuesTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5631 |
< |
s.exec(); |
5630 |
> |
ReduceValuesTask<K,V> s = rights; |
5631 |
> |
if (s != null && !inForkJoinPool()) { |
5632 |
> |
do { |
5633 |
> |
if (s.tryUnfork()) |
5634 |
> |
s.exec(); |
5635 |
> |
} while ((s = s.nextRight) != null); |
5636 |
> |
} |
5637 |
|
return false; |
5638 |
|
} |
5639 |
|
public final V getRawResult() { return result; } |
5689 |
|
} catch (Throwable ex) { |
5690 |
|
return tryCompleteComputation(ex); |
5691 |
|
} |
5692 |
< |
for (ReduceEntriesTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5693 |
< |
s.exec(); |
5692 |
> |
ReduceEntriesTask<K,V> s = rights; |
5693 |
> |
if (s != null && !inForkJoinPool()) { |
5694 |
> |
do { |
5695 |
> |
if (s.tryUnfork()) |
5696 |
> |
s.exec(); |
5697 |
> |
} while ((s = s.nextRight) != null); |
5698 |
> |
} |
5699 |
|
return false; |
5700 |
|
} |
5701 |
|
public final Map.Entry<K,V> getRawResult() { return result; } |
5755 |
|
} catch (Throwable ex) { |
5756 |
|
return tryCompleteComputation(ex); |
5757 |
|
} |
5758 |
< |
for (MapReduceKeysTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5759 |
< |
s.exec(); |
5758 |
> |
MapReduceKeysTask<K,V,U> s = rights; |
5759 |
> |
if (s != null && !inForkJoinPool()) { |
5760 |
> |
do { |
5761 |
> |
if (s.tryUnfork()) |
5762 |
> |
s.exec(); |
5763 |
> |
} while ((s = s.nextRight) != null); |
5764 |
> |
} |
5765 |
|
return false; |
5766 |
|
} |
5767 |
|
public final U getRawResult() { return result; } |
5822 |
|
} catch (Throwable ex) { |
5823 |
|
return tryCompleteComputation(ex); |
5824 |
|
} |
5825 |
< |
for (MapReduceValuesTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5826 |
< |
s.exec(); |
5825 |
> |
MapReduceValuesTask<K,V,U> s = rights; |
5826 |
> |
if (s != null && !inForkJoinPool()) { |
5827 |
> |
do { |
5828 |
> |
if (s.tryUnfork()) |
5829 |
> |
s.exec(); |
5830 |
> |
} while ((s = s.nextRight) != null); |
5831 |
> |
} |
5832 |
|
return false; |
5833 |
|
} |
5834 |
|
public final U getRawResult() { return result; } |
5889 |
|
} catch (Throwable ex) { |
5890 |
|
return tryCompleteComputation(ex); |
5891 |
|
} |
5892 |
< |
for (MapReduceEntriesTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5893 |
< |
s.exec(); |
5892 |
> |
MapReduceEntriesTask<K,V,U> s = rights; |
5893 |
> |
if (s != null && !inForkJoinPool()) { |
5894 |
> |
do { |
5895 |
> |
if (s.tryUnfork()) |
5896 |
> |
s.exec(); |
5897 |
> |
} while ((s = s.nextRight) != null); |
5898 |
> |
} |
5899 |
|
return false; |
5900 |
|
} |
5901 |
|
public final U getRawResult() { return result; } |
5956 |
|
} catch (Throwable ex) { |
5957 |
|
return tryCompleteComputation(ex); |
5958 |
|
} |
5959 |
< |
for (MapReduceMappingsTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
5960 |
< |
s.exec(); |
5959 |
> |
MapReduceMappingsTask<K,V,U> s = rights; |
5960 |
> |
if (s != null && !inForkJoinPool()) { |
5961 |
> |
do { |
5962 |
> |
if (s.tryUnfork()) |
5963 |
> |
s.exec(); |
5964 |
> |
} while ((s = s.nextRight) != null); |
5965 |
> |
} |
5966 |
|
return false; |
5967 |
|
} |
5968 |
|
public final U getRawResult() { return result; } |
6021 |
|
} catch (Throwable ex) { |
6022 |
|
return tryCompleteComputation(ex); |
6023 |
|
} |
6024 |
< |
for (MapReduceKeysToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6025 |
< |
s.exec(); |
6024 |
> |
MapReduceKeysToDoubleTask<K,V> s = rights; |
6025 |
> |
if (s != null && !inForkJoinPool()) { |
6026 |
> |
do { |
6027 |
> |
if (s.tryUnfork()) |
6028 |
> |
s.exec(); |
6029 |
> |
} while ((s = s.nextRight) != null); |
6030 |
> |
} |
6031 |
|
return false; |
6032 |
|
} |
6033 |
|
public final Double getRawResult() { return result; } |
6087 |
|
} catch (Throwable ex) { |
6088 |
|
return tryCompleteComputation(ex); |
6089 |
|
} |
6090 |
< |
for (MapReduceValuesToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6091 |
< |
s.exec(); |
6090 |
> |
MapReduceValuesToDoubleTask<K,V> s = rights; |
6091 |
> |
if (s != null && !inForkJoinPool()) { |
6092 |
> |
do { |
6093 |
> |
if (s.tryUnfork()) |
6094 |
> |
s.exec(); |
6095 |
> |
} while ((s = s.nextRight) != null); |
6096 |
> |
} |
6097 |
|
return false; |
6098 |
|
} |
6099 |
|
public final Double getRawResult() { return result; } |
6153 |
|
} catch (Throwable ex) { |
6154 |
|
return tryCompleteComputation(ex); |
6155 |
|
} |
6156 |
< |
for (MapReduceEntriesToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6157 |
< |
s.exec(); |
6156 |
> |
MapReduceEntriesToDoubleTask<K,V> s = rights; |
6157 |
> |
if (s != null && !inForkJoinPool()) { |
6158 |
> |
do { |
6159 |
> |
if (s.tryUnfork()) |
6160 |
> |
s.exec(); |
6161 |
> |
} while ((s = s.nextRight) != null); |
6162 |
> |
} |
6163 |
|
return false; |
6164 |
|
} |
6165 |
|
public final Double getRawResult() { return result; } |
6219 |
|
} catch (Throwable ex) { |
6220 |
|
return tryCompleteComputation(ex); |
6221 |
|
} |
6222 |
< |
for (MapReduceMappingsToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6223 |
< |
s.exec(); |
6222 |
> |
MapReduceMappingsToDoubleTask<K,V> s = rights; |
6223 |
> |
if (s != null && !inForkJoinPool()) { |
6224 |
> |
do { |
6225 |
> |
if (s.tryUnfork()) |
6226 |
> |
s.exec(); |
6227 |
> |
} while ((s = s.nextRight) != null); |
6228 |
> |
} |
6229 |
|
return false; |
6230 |
|
} |
6231 |
|
public final Double getRawResult() { return result; } |
6284 |
|
} catch (Throwable ex) { |
6285 |
|
return tryCompleteComputation(ex); |
6286 |
|
} |
6287 |
< |
for (MapReduceKeysToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6288 |
< |
s.exec(); |
6287 |
> |
MapReduceKeysToLongTask<K,V> s = rights; |
6288 |
> |
if (s != null && !inForkJoinPool()) { |
6289 |
> |
do { |
6290 |
> |
if (s.tryUnfork()) |
6291 |
> |
s.exec(); |
6292 |
> |
} while ((s = s.nextRight) != null); |
6293 |
> |
} |
6294 |
|
return false; |
6295 |
|
} |
6296 |
|
public final Long getRawResult() { return result; } |
6350 |
|
} catch (Throwable ex) { |
6351 |
|
return tryCompleteComputation(ex); |
6352 |
|
} |
6353 |
< |
for (MapReduceValuesToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6354 |
< |
s.exec(); |
6353 |
> |
MapReduceValuesToLongTask<K,V> s = rights; |
6354 |
> |
if (s != null && !inForkJoinPool()) { |
6355 |
> |
do { |
6356 |
> |
if (s.tryUnfork()) |
6357 |
> |
s.exec(); |
6358 |
> |
} while ((s = s.nextRight) != null); |
6359 |
> |
} |
6360 |
|
return false; |
6361 |
|
} |
6362 |
|
public final Long getRawResult() { return result; } |
6416 |
|
} catch (Throwable ex) { |
6417 |
|
return tryCompleteComputation(ex); |
6418 |
|
} |
6419 |
< |
for (MapReduceEntriesToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6420 |
< |
s.exec(); |
6419 |
> |
MapReduceEntriesToLongTask<K,V> s = rights; |
6420 |
> |
if (s != null && !inForkJoinPool()) { |
6421 |
> |
do { |
6422 |
> |
if (s.tryUnfork()) |
6423 |
> |
s.exec(); |
6424 |
> |
} while ((s = s.nextRight) != null); |
6425 |
> |
} |
6426 |
|
return false; |
6427 |
|
} |
6428 |
|
public final Long getRawResult() { return result; } |
6482 |
|
} catch (Throwable ex) { |
6483 |
|
return tryCompleteComputation(ex); |
6484 |
|
} |
6485 |
< |
for (MapReduceMappingsToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6486 |
< |
s.exec(); |
6485 |
> |
MapReduceMappingsToLongTask<K,V> s = rights; |
6486 |
> |
if (s != null && !inForkJoinPool()) { |
6487 |
> |
do { |
6488 |
> |
if (s.tryUnfork()) |
6489 |
> |
s.exec(); |
6490 |
> |
} while ((s = s.nextRight) != null); |
6491 |
> |
} |
6492 |
|
return false; |
6493 |
|
} |
6494 |
|
public final Long getRawResult() { return result; } |
6547 |
|
} catch (Throwable ex) { |
6548 |
|
return tryCompleteComputation(ex); |
6549 |
|
} |
6550 |
< |
for (MapReduceKeysToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6551 |
< |
s.exec(); |
6550 |
> |
MapReduceKeysToIntTask<K,V> s = rights; |
6551 |
> |
if (s != null && !inForkJoinPool()) { |
6552 |
> |
do { |
6553 |
> |
if (s.tryUnfork()) |
6554 |
> |
s.exec(); |
6555 |
> |
} while ((s = s.nextRight) != null); |
6556 |
> |
} |
6557 |
|
return false; |
6558 |
|
} |
6559 |
|
public final Integer getRawResult() { return result; } |
6613 |
|
} catch (Throwable ex) { |
6614 |
|
return tryCompleteComputation(ex); |
6615 |
|
} |
6616 |
< |
for (MapReduceValuesToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6617 |
< |
s.exec(); |
6616 |
> |
MapReduceValuesToIntTask<K,V> s = rights; |
6617 |
> |
if (s != null && !inForkJoinPool()) { |
6618 |
> |
do { |
6619 |
> |
if (s.tryUnfork()) |
6620 |
> |
s.exec(); |
6621 |
> |
} while ((s = s.nextRight) != null); |
6622 |
> |
} |
6623 |
|
return false; |
6624 |
|
} |
6625 |
|
public final Integer getRawResult() { return result; } |
6679 |
|
} catch (Throwable ex) { |
6680 |
|
return tryCompleteComputation(ex); |
6681 |
|
} |
6682 |
< |
for (MapReduceEntriesToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6683 |
< |
s.exec(); |
6682 |
> |
MapReduceEntriesToIntTask<K,V> s = rights; |
6683 |
> |
if (s != null && !inForkJoinPool()) { |
6684 |
> |
do { |
6685 |
> |
if (s.tryUnfork()) |
6686 |
> |
s.exec(); |
6687 |
> |
} while ((s = s.nextRight) != null); |
6688 |
> |
} |
6689 |
|
return false; |
6690 |
|
} |
6691 |
|
public final Integer getRawResult() { return result; } |
6745 |
|
} catch (Throwable ex) { |
6746 |
|
return tryCompleteComputation(ex); |
6747 |
|
} |
6748 |
< |
for (MapReduceMappingsToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight) |
6749 |
< |
s.exec(); |
6748 |
> |
MapReduceMappingsToIntTask<K,V> s = rights; |
6749 |
> |
if (s != null && !inForkJoinPool()) { |
6750 |
> |
do { |
6751 |
> |
if (s.tryUnfork()) |
6752 |
> |
s.exec(); |
6753 |
> |
} while ((s = s.nextRight) != null); |
6754 |
> |
} |
6755 |
|
return false; |
6756 |
|
} |
6757 |
|
public final Integer getRawResult() { return result; } |
6758 |
|
} |
6759 |
|
|
6760 |
+ |
|
6761 |
|
// Unsafe mechanics |
6762 |
|
private static final sun.misc.Unsafe UNSAFE; |
6763 |
|
private static final long counterOffset; |