[concurrency-interest] How to implement task-local variables (like thread local variables but for Fork/Join tasks)

Dr Heinz M. Kabutz heinz at javaspecialists.eu
Mon Aug 8 09:19:13 EDT 2016


Could you perhaps post some code demonstrating what you are trying to
achieve?

On Monday, 8 August 2016, Per Mildner <perm at sics.se> wrote:

> Ping?
>
> > On 09 Jun 2016, at 22:56, Per Mildner <perm at sics.se <javascript:;>>
> wrote:
> >
> > I need something that should behave like a thread-local variable but for
> a tree of RecursiveAction tasks.
> >
> > That is, a task inherits the task-local variables from the task that
> created it. Looking up a task-local variable is done by traversing the
> chain of parent tasks, looking for special task instances that holds task
> local values.
> >
> > I currently implement this by letting all tasks know their parent (the
> “current task”) which is passed to their constructor. This way I can
> traverse the chain of parents towards the root of the task tree.
> >
> > Keeping track of the current task is done by making all tasks set and
> restore themselves as the “current task” in a thread-local variable in
> their RecursiveAction.compute() but that seems wasteful since it is done
> also when the the task is running in the same thread as its parent task.
> >
> > So, any ideas how to implement this efficiently?
> >
> > Even better, is there a way to make something like this work with the
> default pool?
> >
> > Regards,
> >
> >
> > Per Mildner
> > Per.Mildner at sics.se <javascript:;>
> >
> > (I sent this earlier but it never seemed to arrive at the list. Sorry if
> it gets duplicated.)
> >
> >
>
> Per Mildner                                     Per.Mildner at sics.se
> <javascript:;>
> Swedish Institute of Computer Science (SICS Swedish ICT)
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu <javascript:;>
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>


-- 
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun/Oracle Java Champion
JavaOne Rockstar Speaker
http://www.javaspecialists.eu
Tel: +30 69 75 595 262
Skype: kabutz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160808/f334dcf9/attachment.html>


More information about the Concurrency-interest mailing list