Commit Graph

15 Commits

Author SHA1 Message Date
Alex Bakon
8a9e18b6c6 Remove unused #[allow], replace with #[expect] 2025-06-03 16:07:06 -04:00
Alex Bakon
151c96e52b Apply lint fixes from latest clippy 2025-05-23 10:29:25 -04:00
Alex Konradi
a54e6b5b33 Format with group_imports=StdExternalCrate 2024-08-28 14:52:47 -04:00
akonradi-signal
ef542e3b9f Bump rust compiler version to nightly 2023-09-01 2023-09-12 14:27:08 -04:00
Jordan Rose
49ad15cd06 node: Remove now-unnecessary Vecs from Neon calls 2022-03-08 16:16:23 -08:00
Jordan Rose
b6c6839332 signal-neon-futures: Use Neon's JsPromise to implement our promise()
We still do some extra work to ensure panics are caught and turned
into JavaScript errors, so our promise() function doesn't go away
altogether, but the implementation's much simpler and now more
strongly typed.
2022-03-08 16:16:23 -08:00
Jordan Rose
0d8a530f60 Node: update to Neon 0.10 2022-03-08 16:16:23 -08:00
Jordan Rose
ca37067f5a Update to Neon 0.9.0
- Drop our fork of Neon now that our changes have been integrated
- Adopt rename of EventQueue to Channel
- Add a napi-6 feature to signal-neon-futures to make it easier to test
  under the configuration we're actually shipping
2021-07-26 12:37:42 -07:00
Jordan Rose
e7a0f4d424 Replace block_on and expect_ready with FutureExt::now_or_never
Both futures::executor::block_on and our own expect_ready were being
used to resolve futures that were, in practice, known to be
non-blocking. FutureExt::now_or_never handles that case more lightly
than block_on and more uniformly than expect_ready.

This lets us drop the dependency on the full 'futures' crate down to
just futures_util, which should help with compile time.
2021-07-06 10:30:42 -07:00
Jordan Rose
e1448a8e60 signal-neon-futures: Only run Rust futures on an existing EventQueue
Node can more efficiently handle multiple tasks coming in on the same
queue, so remove the "convenience" APIs that derive a new queue from a
Context, and require an existing EventQueue instead. This cuts more
time off of our decryption benchmark (not checked in).

Additionally, run the first poll for the future synchronously, to
avoid having to wait for the event loop to pick up the task to start
the future.
2021-05-05 17:45:53 -07: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
a58fa94241 Feedback part 3: Add a call_method helper
I made it 'pub' because honestly it's generally useful.
2021-02-05 18:55:01 -08:00
Jordan Rose
449748459c Feedback part 2: remove unnecessary PersistentException helpers 2021-02-05 18:55:01 -08: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