ScopedValue: Capturing current bindings

Attila Kelemen attila.kelemen85 at gmail.com
Thu Jun 1 17:38:41 UTC 2023


David Lloyd <david.lloyd at redhat.com> ezt írta (időpont: 2023. jún. 1., Cs,
19:02):

> What would happen if there was some context which is implemented in some
> way *other* than ScopedValue? For example, using thread locals, or a field
> on Thread, or something like that?
>
>
I understand your implication that I'm being a little bit hypocritical by
concerning myself with SV, but not with others. And of course that is
unfortunate, and I can't do anything about it. But the reason I care more
about the SV scope than others is because I see scope to be more important,
because this looks to me as a promising emerging concept. That is, we could
have a future, where SVs are promoted properly everywhere (for example,
StructuredTaskScope propagates it to the child tasks), What I mean by
"promoted properly" is that at some point (there are various missing tools
for that still) we could have what I would call a "properly scoped"
application, where opening a new scope in `main`, whatever I set there will
be visible to all application code, and if started so (there could be an
implicit virtual scope for `main` as well), then the whole application
would sit in a scope tree (even with concurrency considered) which would
allow me to reason correctness about my code better. In such a world, a DI
framework like I mentioned could be useful (and I believe a lot of
other future APIs could benefit from proper scoping).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230601/c04e7d18/attachment-0001.htm>


More information about the loom-dev mailing list