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

What kind of concurrency/parallelism does this library implement? #175

Open king-of-poppk opened 1 year ago

king-of-poppk commented 1 year ago

It is my understanding that later::later(\() {...}) schedules functions to be executed, that only one such function can run at any given time, and that no such function can run if the session is not idle.

However, I am doubting this interpretation because of the presence of later::create_loop whose documentation says:

Normally, later uses a global event loop for scheduling and running functions. However, in some cases, it is useful to create a private event loop to schedule and execute tasks without disturbing the global event loop. For example, you might have asynchronous code that queries a remote data source, but want to wait for a full back-and-forth communication to complete before continuing in your code – from the caller’s perspective, it should behave like synchronous code, and not do anything with the global event loop (which could run code unrelated to your operation). To do this, you would run your asynchronous code using a private event loop.

Secondly, the C++ API seems to have some threaded implementation.

Could you clarify?