nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
368 stars 19 forks source link

New communication layer between R and threads #102

Closed nx10 closed 2 years ago

nx10 commented 2 years ago

This PR is a rewrite of the IPC and execution layer used to communicate with R from off the main thread.

The excellent later package was used previously but it has some constraints (due to different use cases) that are not appropriate for httpgd.

This PR is a complete replacement with less overhead and modern C++ features and lets us call into R even when the R session is not idle. It basically treats the session as the only worker of a thread pool and allows to individually await execution of C++ futures that run on the main thread.

Fixes: https://github.com/nx10/httpgd/issues/83 Will enable: https://github.com/nx10/httpgd/issues/94 This also will make writing and debugging async communication code for httpgd a lot easier.

I tested this on Windows 10 and a fedora VM, but it would be great if it was tested in more environments before I merge.

eitsupi commented 2 years ago

I ran the sample code in #83 on the Docker image r-base (Debian-based/amd64 platform), and it worked well.

renkun-ken commented 2 years ago

Tried this PR and it works quite nicely!

eitsupi commented 2 years ago

I also tried it with r-base on arm64 (Raspberry Pi 4), and it seems to work just as well.

nx10 commented 2 years ago

Thank you both for testing!