[External] : Re: JEP draft: Scope Locals

Mike Rettig mike.rettig at gmail.com
Mon May 17 17:30:07 UTC 2021


On Mon, May 17, 2021 at 8:43 AM Brian Goetz <brian.goetz at oracle.com> wrote:

>
> How so? How do I know if a snapshot of my variable has occurred?
>
>
> Let's back up a lot of steps; you're deep in proposing a solution when
> you've not even explained what problem you think you're solving.  So
> control question, which I hope will start to expose the assumptions:
>
>    Why do you think its important to know that a snapshot of a variable
> has occurred?
>

>From the JEP:
"In addition, a Snapshot() operation that captures the current set of
inheritable scope locals is provided. This allows context information to be
shared with asynchronous computations."

As the provider of the scoped variable, I'd certainly like to know that my
scoped variable is being passed into a new scope. Threads and executors
introduce new scopes and multiple threads. With life cycles, the scoped
variable can handle nested scopes and multiple threads by using locking
techniques, creating a new instance per scope, or by not supporting nested
scopes at all.  These decisions can vary too based on context. Maybe for
new threads I want a new instance of the scoped variable, but for tasks
it's more efficient to lock on a shared instance.

Mike


More information about the loom-dev mailing list