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

feat(ext/ffi): Non-blocking FFI #12274

Merged
merged 5 commits into from
Oct 5, 2021
Merged

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Sep 30, 2021

Adds support for FFI calls that do not block Deno's event loop. Useful for many cases eg: USB transfers, etc.

const library = Deno.dlopen(libPath, {
  // Set `nonblocking: true` to make the call async
  "sleep": { parameters: "u64", result: "void", nonblocking: true }
});

// Runs the `sleep` call in a dedicated
// blocking thread and resolve when its done
library.sleep(10000).then(() => console.log("Good morning!"))
// Do stuff

ext/ffi/lib.rs Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable and well implemented.

@bartlomieju bartlomieju added this to the 1.15.0 milestone Sep 30, 2021
Copy link
Contributor

@eliassjogreen eliassjogreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@piscisaureus piscisaureus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

5 participants