[concurrency-interest] ParallelIntLoop (was: jsr166y.forkjoin API comments)

Joe Bowbeer joe.bowbeer at gmail.com
Tue Jan 29 16:26:11 EST 2008

On Jan 29, 2008 4:21 AM, Doug Lea wrote:
> David J. Biesack wrote:
> > sometimes you want fork/join but you don't have an array to operate on; you
> > just have a set of indices.
> This suggests creating something like the following.
> class ParallelIntLoop {
>      // Constructors, or maybe factories
>      ParallelIntLoop(int firstIndex, int upperBound);
>      ParallelIntLoop(int firstIndex, int upperBound, int increment);
>      ParallelIntLoop(int firstIndex, int upperBound,
>                      ForkJoinExecutor ex);
>      ParallelIntLoop(int firstIndex, int upperBound, int increment,
>                      ForkJoinExecutor ex);
>      // Apply to each index
>      void apply(IntProcedure p);
>      // Map each index and reduce
>      <T> T reduce(IntToObject<T> op, Reducer<T> r, T base);
>      // Plus scalar specializations, like:
>      long reduce(IntToLong op, LongReducer r, long base);
>      // Plus basic layered forms, including
>      <T> T max(IntToObject<T> op);
> }

Could a factory create the necessary forkjoin driver task instead?
Alternatively, provide an abstract forkjoin driver task that can be
customized for linear algebra over multidimensional arrays?

Currently there's no middle ground between the few raw ForkJoinTasks
and the freeze-dried PA classes, and I'm thinking there should be.


More information about the Concurrency-interest mailing list