Package at.jku.ssw.fp.sect08_2
Class ReduceTask<V>
- java.lang.Object
-
- java.util.concurrent.ForkJoinTask<V>
-
- java.util.concurrent.RecursiveTask<V>
-
- at.jku.ssw.fp.sect08_2.ReduceTask<V>
-
- Type Parameters:
V
- the type of values processed
- All Implemented Interfaces:
Serializable
,Future<V>
class ReduceTask<V> extends RecursiveTask<V>
Task for simulating the reduce operation of parallel streams including log information.- Author:
- Herbert Praehofer
-
-
Field Summary
Fields Modifier and Type Field Description private BinaryOperator<V>
accu
The binary operator for the reductionprivate BinaryOperator<V>
comb
The binary operator for the reductionprivate V
identity
The identity value for the reduction(package private) V
result
The reduction valueprivate Spliterator<V>
spltr
The spliterator for this taskprivate static int
THRESHOLD
Threshold for splitting
-
Constructor Summary
Constructors Constructor Description ReduceTask(Spliterator<V> spltr, V identity, BinaryOperator<V> accu, BinaryOperator<V> comb)
Constructor initializing the task.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected V
compute()
Executes this task.-
Methods inherited from class java.util.concurrent.RecursiveTask
exec, getRawResult, setRawResult
-
Methods inherited from class java.util.concurrent.ForkJoinTask
adapt, adapt, adapt, cancel, compareAndSetForkJoinTaskTag, complete, completeExceptionally, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollSubmission, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, reinitialize, setForkJoinTaskTag, tryUnfork
-
-
-
-
Field Detail
-
THRESHOLD
private static final int THRESHOLD
Threshold for splitting- See Also:
- Constant Field Values
-
spltr
private final Spliterator<V> spltr
The spliterator for this task
-
identity
private final V identity
The identity value for the reduction
-
accu
private final BinaryOperator<V> accu
The binary operator for the reduction
-
comb
private final BinaryOperator<V> comb
The binary operator for the reduction
-
result
V result
The reduction value
-
-
Constructor Detail
-
ReduceTask
public ReduceTask(Spliterator<V> spltr, V identity, BinaryOperator<V> accu, BinaryOperator<V> comb)
Constructor initializing the task.- Parameters:
spltr
- the spliteratoridentity
- the identity value for the reductionaccu
- the accumulator function for the sequential reductioncomb
- the combiner function for the reduction
-
-
Method Detail
-
compute
protected V compute()
Executes this task. Either splits or does a sequential reduction.- Specified by:
compute
in classRecursiveTask<V>
- Returns:
- the reduced value
-
-