[Rcpp-devel] RInside and multi-threading

Darren Cook darren at dcook.org
Sun Feb 12 03:47:25 CET 2012

I think the correct approach for R is to have a single global instance
(or on the stack in main()) (e.g. [1]).

If your application is multi-threaded, what extra steps do you need to
take? Does every call to the RInside object have to be protected by a
mutex? Or, I wonder if some read-only accesses could be done in
parallel? E.g. a data.frame has been created. Could 2+ threads access
parts of that data.frame in parallel (as long as I'm sure no thread will
update it)?

I found [2], suggesting that this is okay for RServe. Implying it would
be okay for RInside too?



[2]: http://www.rosuda.org/Rserve/
"Rserve is thread safe across connections, but eval methods are not
thread safe within one connection. This means that multiple threads
should not use the same connection unless they guarantee that no eval
calls are run in parallel."

Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

More information about the Rcpp-devel mailing list