Closed wlandau closed 5 months ago
I think I've figured a way of implementing this completely event-driven approach by polling read activity on file descriptors internal to NNG sockets – plugging into R’s event handlers similar to later
. I’ve touched on this with @wlandau already, @jcheng5 happy to discuss with you whenever you wish.
Ended up discussing this with @wlandau and @shikokuchuo extensively over email and Zoom, my take on it is this draft PR on nanonext. The TL;DR is that it's not really something for the promises package itself to handle, rather, each execution engine needs its own way of detecting relevant events and can use the {later} package to either poll (if necessary) or to move notifications from background threads to the main thread (preferred).
mirai
andcrew
are new packages for distributed distributed computing similar tofuture
. They can both leverage their parallel computing capabilities to create custom promise objects, as described at https://shikokuchuo.net/mirai/articles/promises.html formirai
and at https://wlandau.github.io/crew/articles/promises.html forcrew
(also c.f. https://github.com/wlandau/crew/issues/147, https://github.com/wlandau/crew/pull/149). The promises seem to work, but they do rely on polling withlater::later()
, which may not be as efficient or as kind to the CPU as a truly event-driven approach.It would be great if
promises
could provide a general solution for triggering callbacks asynchronously, or if the documentation could describe how to implement a successful event-driven pattern. I am not sure if anything like this currently exists, but there may be possibilities using thenanonext
package.nanonext
is a low-level R client for the NNG messaging library, which in turn provides network protocols, asynchronous I/O, and perhaps most importantly for this issue, synchronization primitives such as condition variables which can be configured to respond to local network events.This thread is part of a follow-up on recent conversations with @shikokuchuo and @jcheng5.