[concurrency-interest] Composing ForkJoin tasks
richhickey at gmail.com
Wed Jul 22 10:23:34 EDT 2009
There are many instances in FJ where it states "This method may be
invoked only from within ForkJoinTask computations." Is
ForkJoinTask.getPool() the correct way to detect when one is within a
It seems desirable if one is in a ForkJoin task and needs to execute
others, it would be preferable to fork/invokeAll them rather than use
a fresh ForkJoinPool.execute, or does it not matter much?
Obviously in a centrally-authored nested computation one knows what's
going on, the situation I'm talking about is arbitrary nested
composition of generic things like parallel map functions.
Is ForkJoinTask.getPool() guaranteed to be safe and valid from any
thread, and a sufficient indicator of running "within a ForkJoinTask
computation"? If so, I think perhaps its doc string could better
indicate that, something like:
"Returns the pool hosting the current task execution, or null if the
current thread is executing outside of any ForkJoin computation."
More information about the Concurrency-interest