Skip to content

Commit

Permalink
use interactive threadpool if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jun 13, 2024
1 parent feb428a commit c99aaf4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function _start()
elseif (repl_was_requested || is_interactive)
# Run the Base `main`, which will either load the REPL stdlib
# or run the fallback REPL
ret = fetch(Threads.@spawn repl_main(ARGS))
ret = fetch(Threads.@spawn :interactive repl_main(ARGS))
end
ret === nothing && (ret = 0)
ret = Cint(ret)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function beep(s::PromptState, duration::Real=options(s).beep_duration,
isinteractive() || return # some tests fail on some platforms
s.beeping = min(s.beeping + duration, maxduration)
let colors = Base.copymutable(colors)
errormonitor(Threads.@spawn begin
errormonitor(Threads.@spawn :interactive begin
trylock(s.refresh_lock) || return
try
orig_prefix = s.p.prompt_prefix
Expand Down Expand Up @@ -2829,7 +2829,7 @@ function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_s
activate(prompt, s, term, term)
old_state = mode(s)
l = Base.ReentrantLock()
t = Threads.@spawn while true
t = Threads.@spawn :interactive while true
wait(s.async_channel)
status = @lock l begin
fcn = take!(s.async_channel)
Expand Down
10 changes: 5 additions & 5 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ function start_repl_backend(repl_channel::Channel{Any}, response_channel::Channe
# Maintain legacy behavior of asynchronous backend
backend = REPLBackend(repl_channel, response_channel, false)
# Assignment will be made twice, but will be immediately available
backend.backend_task = Threads.@spawn start_repl_backend(backend; get_module)
backend.backend_task = Threads.@spawn :interactive start_repl_backend(backend; get_module)
return backend
end

"""
start_repl_backend(backend::REPLBackend)
Call directly to run backend loop on current Task.
Use Threads.@spawn for run backend on new Task.
Use Threads.@spawn :interactive for run backend on new Task.
Does not return backend until loop is finished.
"""
Expand Down Expand Up @@ -495,12 +495,12 @@ function run_repl(repl::AbstractREPL, @nospecialize(consumer = x -> nothing); ba
end
get_module = () -> active_module(repl)
if backend_on_current_task
t = Threads.@spawn run_frontend(repl, backend_ref)
t = Threads.@spawn :interactive run_frontend(repl, backend_ref)
errormonitor(t)
Base._wait2(t, cleanup)
start_repl_backend(backend, consumer; get_module)
else
t = Threads.@spawn start_repl_backend(backend, consumer; get_module)
t = Threads.@spawn :interactive start_repl_backend(backend, consumer; get_module)
errormonitor(t)
Base._wait2(t, cleanup)
run_frontend(repl, backend_ref)
Expand Down Expand Up @@ -1266,7 +1266,7 @@ function setup_interface(
end
# load Pkg on another thread if available so that typing in the dummy Pkg prompt
# isn't blocked, but instruct the main REPL task to do the transition via s.async_channel
t_replswitch = Threads.@spawn begin
t_replswitch = Threads.@spawn :default begin
REPLExt = load_pkg()
if REPLExt isa Module && isdefined(REPLExt, :PkgCompletionProvider)
put!(s.async_channel,
Expand Down

0 comments on commit c99aaf4

Please sign in to comment.