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

Non-blocking FFI: Progress events #12946

Closed
kriszyp opened this issue Nov 30, 2021 · 2 comments
Closed

Non-blocking FFI: Progress events #12946

kriszyp opened this issue Nov 30, 2021 · 2 comments
Labels
FFI Related to Foreign Function Interface APIs suggestion suggestions for new features (yet to be agreed)

Comments

@kriszyp
Copy link

kriszyp commented Nov 30, 2021

When running an asynchronous FFI function (which is now possible, thank you!) that may be performing a long-running operation (in a separate thread), it is often valuable for the FFI function to be able to communicate back to the main JS thread during the course of its execution. Currently, the only communication back to the main thread is the completion of the FFI function, but being able to send multiple updates would be of significant value. This could potentially be done by being able to enqueue some type of "progress" or other notification events into the main JS event queue from the the FFI function that is executing.

Prior art from Node.js includes thread-safe functions and Nan::AsyncProgressWorker.

@bartlomieju bartlomieju added FFI Related to Foreign Function Interface APIs suggestion suggestions for new features (yet to be agreed) labels Dec 1, 2021
@aapoalas
Copy link
Collaborator

Disclaimer: I'm not a Deno developer nor an expert in pretty much anything related.

I think the JS-native implementation of this would be an async iterator. However, that would require a very particular API for there to be any hope of Deno being able to offer an out-of-the-box solution. That, or there would need to be some sort of parametrization on the FFI calls.

It sort of seems to me like this would necessarily need to be user-land implemented.

@littledivy
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FFI Related to Foreign Function Interface APIs suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

4 participants