Dewey Dunnington created ARROW-15841:
----------------------------------------
Summary: [R] Implement SafeCallIntoR to safely call the R API from
another thread
Key: ARROW-15841
URL: https://issues.apache.org/jira/browse/ARROW-15841
Project: Apache Arrow
Issue Type: Bug
Components: R
Reporter: Dewey Dunnington
In ARROW-9235 we have a problem where we need to evaluate code (may be C++ that
calls the R API in a way that may allocate R memory or literal R code) on the R
main thread. As discussed in the pull request (
https://github.com/apache/arrow/pull/12323#issuecomment-1054726309 ), there are
other times that this has come up and will come up in the future (e.g.,
evaluating user-defined R functions from the query engine, implementing
extension types from R).
After discussing with [~westonpace], it seems like it is worth investing in a
{{SafeCallFromR()}} C++ function that lives in the R bindings. The initial
approach (that may need to be altered as we go) will be to
- have a global object that is initialized at the beginning of a C++ call from
R to specific functions (and released on exit) that maintains some list of
tasks that need to run on the R main thread and an event loop to periodically
evaluate them while background tasks are running.
- define a {{SafeCallFromR()}} C++ function that adds a task to the global
object and waits for the result to come back.
(with apologies to Weston if I mischaracterized our conversation!)
--
This message was sent by Atlassian Jira
(v8.20.1#820001)