ScopedValue: Capturing current bindings

Attila Kelemen attila.kelemen85 at gmail.com
Thu Jun 1 22:14:26 UTC 2023


>
>
> But this is a cross thread relationship, right? The scoping in this case
> is transversal to lexical scoping or thread scoping. A bean that is bound
> to some sub-context of the application context, is bound during a time that
> is defined by the application life cycle, not by some call chain active in
> some thread. Why would one implement all this inside ScopedValue?
>
>
The way I imagine, is that in the future you could design an application
around scopes (in the abstract, SV is just a visible thing in the scope).
That is, all your application is a single tree of scopes, and all the
application code is within a scope. In this world, scopes would be a
natural candidate to be used as DI contexts, because scopes have a well
defined life-cycle, and that would make arguing about the lifetime and
ownership (and who can have access to them) of resources easy. To me at
least it is always a big pain point that it is hard to prove that a
resource that has a given lifetime is not used outside its lifetime, and
also that I can limit its life to a minimum. And since scopes would/could
be the owner of resources, it makes sense to inject them via the scopes as
well (since you know that whatever you injected this way is alive at that
point).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230602/08f1a28a/attachment.htm>


More information about the loom-dev mailing list