Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use private event loop where necessary #80

Open
cderv opened this issue Aug 2, 2019 · 2 comments
Open

Use private event loop where necessary #80

cderv opened this issue Aug 2, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@cderv
Copy link
Collaborator

cderv commented Aug 2, 2019

This seems important to not conflict with other later loop while in !async mode like maybe in wait function.

private event loop are used in chromote and also will be pagedown::chrome_print

@wch
Copy link

wch commented Aug 9, 2019

Here's a summary of how chromote uses a private event loop. I think you should be able to adapt it for crrri.

With this setup, whenever you call run_now() (on the main/global loop), or when the R console is idle, the behavior will be essentially the same as the case where no private loop is used. However, it is also possible to run the private loop by itself, with something like run_now(loop = private_loop), and that lets you wait for something to happen without accidentally running a callback that belongs to someone else.

Note that currently when Chromote schedules the private loop to be run from the main loop, it does so every .01 seconds. This is not ideal, and in the future we would like to make it unnecessary by providing an option when the private loop is created.

Chromote also has a function called synchronize, which will block until a promise resolves. Note that this code is a bit experimental. Also, much of the complexity is present because it tries to gracefully handle interrupts.
https://github.com/rstudio/chromote/blob/f53a70b/R/synchronize.R#L99-L148

@cderv cderv added the enhancement New feature or request label Aug 11, 2019
@cderv cderv self-assigned this Oct 27, 2019
@cderv
Copy link
Collaborator Author

cderv commented May 7, 2020

Look also at new feature of private loop autorun rstudio/chromote#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants