Commit Graph

4 Commits

Author SHA1 Message Date
Alex Bakon
a5f2d4248c Migrate signal-neon-futures Node tests to ESM and upgrade deps 2025-09-18 16:05:52 -04:00
Jordan Rose
e77584753a signal-neon-futures: Add a Node benchmark for a single round trip
It turns out this takes less than a millisecond, at least when the
event loop is empty, but the setup might still be useful in the
future. Run with `cargo bench -p signal-neon-futures`.
2021-04-16 15:14:22 -07:00
Jordan Rose
c0a0a58189 Feedback part 1: renames and comments
In particular, I got the terms "fulfill" and "resolve" mixed up. This
version should have the correct use of "settled", "fulfilled",
"rejected", and (in rare cases) "resolved".
2021-02-05 18:55:01 -08:00
Jordan Rose
2d059643e1 Node: allow Rust async blocks to wait on JavaScript futures
Neon provides a way to expose *synchronous* JavaScript functions from
Rust. This means that if Rust wants to wait for the result of a
JavaScript promise, it can at best return a callback to continue its
work when the promise resolves. This does not naturally compose with
Rust's `async`, which works in terms of Futures.

This commit adds a new crate, signal-neon-futures, that provides
functionality for (1) wrapping JavaScript futures so they can be
awaited on in Rust, and (2) producing a JavaScript promise that wraps
a Rust future. It does so by synchronously resuming execution of the
Rust future whenever an awaited JavaScript promise is resolved.
2021-02-04 10:22:58 -08:00