ScopedValue: Capturing current bindings

Andrew Haley aph-open at littlepinkcloud.com
Fri Jun 2 09:18:29 UTC 2023


On 6/1/23 20:06, Attila Kelemen wrote:
> As for your concern: You are already screwed :) In fact, I have realized
> that I have a (horrible) way to implement what I want with
> `StructuredTaskScope`, because when I'm binding the factory in my example,
> I can open a new STS, fork a task immediately which will just stop and wait
> and when down the line the "resource"

What's horrible about it? You create a bunch of threads in a
StructuredTaskScope, and the threads handle tasks in that
context. Everything is nicely structured, so there's no need to
do anything underhand. Any time you need another worker thread
a StructuredTaskScope can fork one.

You're using scopes in exactly the way they are intended to be used.
No extra runtime checking is needed.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the loom-dev mailing list