@@ -334,19 +334,23 @@ PATH_cache_task::Union{Task,Nothing} = nothing
334
334
PATH_cache_condition:: Union{Threads.Condition, Nothing} = nothing # used for sync in tests
335
335
next_cache_update:: Float64 = 0.0
336
336
function maybe_spawn_cache_PATH ()
337
- global PATH_cache_task, next_cache_update
337
+ global PATH_cache_task, PATH_cache_condition, next_cache_update
338
+ # Extract to local variables to enable flow-sensitive type inference for these global variables
339
+ PATH_cache_task_local = PATH_cache_task
340
+ PATH_cache_condition_local = PATH_cache_condition
338
341
@lock PATH_cache_lock begin
339
- PATH_cache_task isa Task && ! istaskdone (PATH_cache_task ) && return
342
+ PATH_cache_task_local isa Task && ! istaskdone (PATH_cache_task_local ) && return
340
343
time () < next_cache_update && return
341
344
PATH_cache_task = Threads. @spawn begin
342
345
REPLCompletions. cache_PATH ()
343
346
@lock PATH_cache_lock begin
344
347
next_cache_update = time () + 10 # earliest next update can run is 10s after
345
348
PATH_cache_task = nothing # release memory when done
346
- PATH_cache_condition != = nothing && notify (PATH_cache_condition )
349
+ PATH_cache_condition_local != = nothing && notify (PATH_cache_condition_local )
347
350
end
348
351
end
349
- Base. errormonitor (PATH_cache_task)
352
+ PATH_cache_task_local = PATH_cache_task
353
+ Base. errormonitor (PATH_cache_task_local)
350
354
end
351
355
end
352
356
0 commit comments