Skip to content

Commit

Permalink
spawn prompt! to free it from sticky repl task
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jun 13, 2024
1 parent 45dc422 commit 0a7c5a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2740,10 +2740,12 @@ end

function run_interface(terminal::TextTerminal, m::ModalInterface, s::MIState=init_state(terminal, m))
while !s.aborted
buf, ok, suspend = prompt!(terminal, m, s)
# spawn this so because the main repl task is sticky (due to use of @async and _wait2)
# and we want to not block typing when the repl task thread is busy
buf, ok, suspend = fetch(Threads.@spawn :interactive prompt!(terminal, m, s))
while suspend
@static if Sys.isunix(); ccall(:jl_repl_raise_sigtstp, Cint, ()); end
buf, ok, suspend = prompt!(terminal, m, s)
buf, ok, suspend = fetch(Threads.@spawn :interactive prompt!(terminal, m, s))
end
Base.invokelatest(mode(state(s)).on_done, s, buf, ok)
end
Expand Down Expand Up @@ -2829,7 +2831,7 @@ function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_s
activate(prompt, s, term, term)
old_state = mode(s)
l = Base.ReentrantLock()
t = @async while true
t = Threads.@spawn :interactive while true
wait(s.async_channel)
status = @lock l begin
fcn = take!(s.async_channel)
Expand Down

0 comments on commit 0a7c5a9

Please sign in to comment.