[concurrency-interest] ForkJoin updates
dl at cs.oswego.edu
Sun Mar 4 11:07:11 EST 2012
On 01/25/12 20:06, Doug Lea wrote:
> As promised for a while now, some updates to ForkJoin
> are available from the usual places linked from
> 3. One small API addition: Explicit support for task marking.
> It was cruel to tell people that they could use FJ for things
> like graph traversal but not have a simple way to mark tasks
> so they won't be revisited while processing a graph (among a few
> other common use cases).
... and almost equally cruel to only allow a single kind of mark.
These have been changed to methods that operate on any "short" tag,
which allows marking with different flavors, marking multiple subtasks,
etc. The use of "short" here is enough to support a much broader
range of uses. The methods are a little annoying to use though because
there are no "short" literals, so you have to say for example:
if (task.compareAndSetForkJoinTaskTag((short)0, (short)1)) ...
to conditionally add a simple mark.
(No, we can't support the nicer-to-use "int" without hurting other
Sorry to those who have already been using the "mark" versions.
(But this is one reason why we let improvements sit in our repository
for a while before integrating with OpenJDK etc.)
It should be easy to change your code to use tags instead.
More information about the Concurrency-interest