[concurrency-interest] Parameterized CountedCompleters

Doug Lea dl at cs.oswego.edu
Thu Aug 16 08:42:19 EDT 2012

While the most common use cases for CountedCompleters are for
void actions, there is no good reason to force them to be.
Several people have wanted to use result-bearing forms, so
they now support this.

They now can/should/must be declared as CountedCompleter<T>,
and you can override method getRawResult to return any appropriate
result that will be relayed to any call to invoke, join, etc.

Unlike the case of RecursiveTask<T>, we have no idea how you are
representing result values, so the protected setRawResult(T x)
method is by default a no-op. You can override this if desired
to do some sort of result maintenance, but typically won't.

This turns out to be a binary-compatible change, so there's
no need to adjust existing usages immediately. And it is even
source compatible, although will encounter may "raw type"
compiler warnings.

At some point, you'll want to replace
   class MyCC extends CountedCompleter
   class MyCC extends CountedCompleter<Void>

and constructors of form
   MyCC(CountedCompleter p, ...) { super(p); ...}
   MyCC(CountedCompleter<?> p, ...) { super(p); ...}
and similarly for any other methods accepting CountedCompleters).

This change is now in jsr166y, jsr166e, and j.u.c jars and sources.


More information about the Concurrency-interest mailing list