Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,23 @@ PATH_cache_condition::Union{Threads.Condition, Nothing} = nothing # used for syn
next_cache_update::Float64 = 0.0
function maybe_spawn_cache_PATH()
global PATH_cache_task, PATH_cache_condition, next_cache_update
# Extract to local variables to enable flow-sensitive type inference for these global variables
PATH_cache_task_local = PATH_cache_task
PATH_cache_condition_local = PATH_cache_condition
@lock PATH_cache_lock begin
# Extract to local variables to enable flow-sensitive type inference for these global variables
PATH_cache_task_local = PATH_cache_task
PATH_cache_task_local isa Task && !istaskdone(PATH_cache_task_local) && return
time() < next_cache_update && return
PATH_cache_task = Threads.@spawn begin
REPLCompletions.cache_PATH()
@lock PATH_cache_lock begin
next_cache_update = time() + 10 # earliest next update can run is 10s after
PATH_cache_task = nothing # release memory when done
PATH_cache_condition_local !== nothing && notify(PATH_cache_condition_local)
PATH_cache_task = PATH_cache_task_local = Threads.@spawn begin
try
REPLCompletions.cache_PATH()
finally
@lock PATH_cache_lock begin
next_cache_update = time() + 10 # earliest next update can run is 10s after
PATH_cache_task = nothing # release memory when done
PATH_cache_condition_local = PATH_cache_condition
PATH_cache_condition_local !== nothing && notify(PATH_cache_condition_local)
end
end
end
PATH_cache_task_local = PATH_cache_task
Base.errormonitor(PATH_cache_task_local)
end
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ function test_only_arm_cache_refresh()
# force the next cache update to happen immediately
REPL.REPLCompletions.next_cache_update = 0
end
return REPL.REPLCompletions.PATH_cache_condition
return nothing
end

function test_only_wait_cache_path_done()
Expand Down