-
Notifications
You must be signed in to change notification settings - Fork 59
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
interact with R event loops #49
Comments
Eventloop was implemented in RCalling.jl and Rif.jl. See for example this link. The code was written in C, however, it should be easy to port it to Julia. I can submit a PR this afternoon. |
Please checkout the current master branch for the eventloop. Basically, there are two functions: |
Once we have callbacks sorted out, we could automate this using |
In the eventloop, there was a dirty fix related to For a while, I only think that it is needed for julia> using RCall
julia> reval("gc()")
RCall.RObject{RCall.RealSxp}
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 219236 11.8 460000 24.6 350000 18.7
Vcells 322397 2.5 786432 6.0 786432 6.0
julia> unsafe_load(cglobal((:R_interrupts_pending,RCall.libR),Cint))
0
julia> ^C
julia> unsafe_load(cglobal((:R_interrupts_pending,RCall.libR),Cint))
1
julia> reval("gc()")
ERROR: RCall.jl
in error at error.jl:22
in reval_p at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:11
in reval_p at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:19
in reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:29
in reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:31
julia> unsafe_load(cglobal((:R_interrupts_pending,RCall.libR),Cint))
0
julia> reval("gc()")
signal (11): Segmentation fault: 11
sexp at /Users/Randy/.julia/v0.4/RCall/src/types.jl:332
jlcall_sexp_21406 at (unknown line)
reval_p at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:18
reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:29
jlcall_reval_21501 at (unknown line)
reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:31
jl_apply at /opt/local/julia/src/interpreter.c:55
eval at /opt/local/julia/src/interpreter.c:213
jl_toplevel_eval_flex at /opt/local/julia/src/toplevel.c:527
jl_toplevel_eval_in at /opt/local/julia/src/builtins.c:579
eval_user_input at REPL.jl:62
jlcall_eval_user_input_21271 at (unknown line)
anonymous at REPL.jl:92
jl_apply at /opt/local/julia/src/task.c:241
Selection: But interestingly, if It means that we might need to check the value of |
One possible solution is to disable signal handling if !Rinited
unsafe_store!(cglobal((:R_SignalHandlers,libR),Cint),0)
argv = ["REmbeddedJulia","--silent","--no-save"]
i = ccall((:Rf_initEmbeddedR,libR),Cint,(Cint,Ptr{Ptr{UInt8}}),length(argv),argv)
i > 0 || error("initEmbeddedR failed. Try restarting and running Pkg.build(\"RCall\").")
global const Rproc = Rinstance(i)
end |
Though the eventloop implementation is still primitive, I believe this thread could be closed (at least for now). |
One thought: in the timer loop we could check if there are any open graphics devices, and if not, close the timer? |
If I am correct, the timer loop is also needed for some X11 applications and they are not necessary graphics. |
We could create a graphic-specific one (started by a hook), and a general (manual) one? |
In order to get features like graphics windows working correctly, we need to be able to interact with the R event loops. Some details are covered in R-ext §8.
From what I understand, we need to implement (some of) the functionality provided by
run_Rmainloop
.The text was updated successfully, but these errors were encountered: