-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
ProductionMonitoring.jl/src/Tracing/scoped_values_context.jl
Lines 31 to 42 in a278726
| function scoped_values_set_context(pair::Pair{<:ScopedValue}, rest::Pair{<:ScopedValue}...) | |
| ct = Base.current_task() | |
| original_scope = ct.scope::Union{Nothing, ScopedValues.Scope} | |
| ct.scope = ScopedValues.Scope(original_scope, pair, rest...) | |
| return original_scope | |
| end | |
| function scoped_values_reset_context(old) | |
| ct = current_task() | |
| ct.scope = old | |
| return nothing | |
| end |
The direct modification of these fields is undefined behavior. JuliaLang/julia#52309
When I was asked about this in JuliaLang/ScopedValues.jl#14 (comment) I stated that this optimization was planned.
scope = currrent_scope()
scoped_values_reset_context(#=...=#)
scope = current_scope()
Is now being transformed to:
scope = currrent_scope()
scoped_values_reset_context(#=...=#)
The right way IMO is to "snapshot" the scope with a potential list of scoped values into a PersistentDict and then to write with(snapshot...) do f that sets those scopedvalues to those values again.
(found through Github search for ScopedValue)
Metadata
Metadata
Assignees
Labels
No labels