Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module update #45

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion src/RemoteREPL.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module RemoteREPL

export connect_repl, serve_repl, @remote, connect_remote
export connect_repl, serve_repl, @remote, connect_remote, putmodule!

const DEFAULT_PORT = 27754
const PROTOCOL_MAGIC = "RemoteREPL"
const PROTOCOL_VERSION = UInt32(1)

const STDOUT_PLACEHOLDER = Symbol("#RemoteREPL_STDOUT_PLACEHOLDER")
const NEWMODULE_CHANNEL = Channel{Module}(1)

include("tunnels.jl")
include("server.jl")
Expand Down
14 changes: 13 additions & 1 deletion src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ mutable struct ServerSideSession
display_properties::Dict
in_module::Module
end
function setmodule!(sss::ServerSideSession, mod::Module)
sss.in_module = mod
end

function putmodule!(mod::Module)
# empty channel
while isready(NEWMODULE_CHANNEL)
take!(NEWMODULE_CHANNEL)
end
# put new module
put!(NEWMODULE_CHANNEL, mod)
end

Base.isopen(session::ServerSideSession) = isopen(session.socket)
Base.close(session::ServerSideSession) = close(session.socket)
Expand Down Expand Up @@ -102,6 +114,7 @@ function evaluate_requests(session, request_chan, response_chan)
try
request = take!(request_chan)
result = eval_message(session, request...)
isready(NEWMODULE_CHANNEL) && setmodule!(session, take!(NEWMODULE_CHANNEL))
if !isnothing(result)
put!(response_chan, result)
end
Expand Down Expand Up @@ -285,4 +298,3 @@ function serve_repl(server::Base.IOServer; on_client_connect=nothing)
end
end
end