r-lib / later

Schedule an R function or formula to run after a specified period of time.
https://r-lib.github.io/later
Other
137 stars 27 forks source link

Invoke R callbacks in pure R #108

Open jcheng5 opened 4 years ago

jcheng5 commented 4 years ago

Consider rewriting execCallback to not invoke R-based callbacks with our own C/C++ code on the call stack. This would remove our invocation of R_TopLevelExec which causes issues with withCallingHandlers (like expect_warning).

We could rewrite execCallback to only take the callback in C++, and return control to R which will invoke it. There will be some challenge here to maintain the do/while loop logic without inadvertently introducing changes.

atheriel commented 4 years ago

I'm very strongly interested in this, since I have a package that issues warnings via later() from a C background thread.

wch commented 4 years ago

@atheriel I started work on this several months ago but I didn't have time to finish. Unfortunately I won't have time to get to it probably for the rest of the year.

The branch is callbacks-r. If you're interested in picking it up, I could sketch out how I was thinking of implementing it.

dselivanov commented 4 years ago

@wch I don't see callbacks-r on github.

wch commented 4 years ago

@dselivanov Sorry, I forgot to push the branch before. It's there now.

tzakharko commented 3 years ago

I wanted to ask whether this change is still planned? Not being able to handle conditions is painful...