[concurrency-interest] jsr166y.forkjoin API comments

David J. Biesack David.Biesack at sas.com
Tue Jan 29 10:23:27 EST 2008


> Date: Tue, 29 Jan 2008 07:21:52 -0500
> From: Doug Lea <dl at cs.oswego.edu>
> CC: concurrency-interest at cs.oswego.edu
> 
> 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);
> }

> Plus a version using longs rather than ints.
> 
> What do you think?

I suggest the name ParallelIntRange -- that is, the class is not a loop, anymore than ParallelArray is.

However, once you add things like filter and map, perhaps this
becomes nothing more than ParallelIntSet (if indeed you have plans
for that), in which case we simply need the appropriate
ParallelIntSet factory method rather than a new ParallelIntLoop class.

class ParallelIntSet {

   ParallelIntSet createRange(int firstIndex, int upperBound, ForkJoinExecutor ex) 
   ParallelIntSet createRange(int firstIndex, int upperBound, int increment, ForkJoinExecutor ex) 
   ...

> -Doug

-- 
David J. Biesack     SAS Institute Inc.
(919) 531-7771       SAS Campus Drive
http://www.sas.com   Cary, NC 27513



More information about the Concurrency-interest mailing list