ScopedValue.runWhere not returning scope

robert engels robaho at icloud.com
Tue Jun 18 10:11:55 UTC 2024


When a fork always uses a new context it’s fine. 

I was trying to make it work with no user code changes for tracing. 

The branch I posted does this with a subclass of the StructuredScope which could be injected by a framework. 

> On Jun 18, 2024, at 3:45 AM, Andrew Haley <aph-open at littlepinkcloud.com> wrote:
> 
> On 6/17/24 23:15, Robert Engels wrote:
>> The “tracing context” is going to be shared across all of the tasks (via
>>  the ScopedValue). So if a task does TracingContext.get().newSpan() it
>> will clobber other tasks doing the same - i.e. push/pop cannot work. -
>> in terms of the “current span” - since the ScopedValue is shared.
> 
> Like this, no?
> 
>        import static ScopedValue.where;
>        ...
> 
>        try (var scope = new StructuredTaskScope<String>()) {
> 
>            where(CONTEXT, new TraceContext()).run(scope.fork(() -> childTask1()));
>            ...
>        }
> 
> --
> 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