Skip to content

Threadsafe Handles #622

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

Merged
merged 8 commits into from
Jan 5, 2021
Merged

Threadsafe Handles #622

merged 8 commits into from
Jan 5, 2021

Conversation

kjvalencik
Copy link
Member

@kjvalencik kjvalencik commented Nov 5, 2020

Implementation of neon-bindings/rfcs#32

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik
@kjvalencik kjvalencik force-pushed the kv/threadsafe-handles branch from e67b1d1 to ab9ff25 Compare December 29, 2020 19:04

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik
@kjvalencik kjvalencik changed the title WIP: Threadsafe Handles Threadsafe Handles Jan 4, 2021
Copy link
Collaborator

@dherman dherman left a comment

Choose a reason for hiding this comment

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

Looks awesome. I made a few suggestions but I'll leave them all to your discretion.

@@ -0,0 +1,161 @@
use neon_runtime::raw::Env;

This comment was marked as resolved.

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik
@kjvalencik
Copy link
Member Author

All possible combinations of added feature flags were tested to ensure the code compiles without unused warnings:

cargo check && cargo check --features event-handler-api && cargo check --no-default-features --features napi-1 && cargo check --no-default-features --features napi-4 && cargo check && cargo check --no-default-features --features napi-4,event-queue-api && cargo check --no-default-features --features napi-1,event-queue-api && cargo check --no-default-features --features napi-4,event-handler-api

Copy link
Collaborator

@dherman dherman left a comment

Choose a reason for hiding this comment

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

Looks good to me. One suggestion for a clearer failure message if someone tries to use the deprecated EventHandler API with N-API.

impl EventHandler {
#[cfg(feature = "napi-1")]
pub fn new<'a, C: Context<'a>, T: Value>(cx: &C, this: Handle<T>, callback: Handle<JsFunction>) -> Self {
unimplemented!()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe include a panic message that explains that this experimental API is not supported in the N-API backend, with a suggestion for an alternative.

Verified

This commit was signed with the committer’s verified signature.
kjvalencik K.J. Valencik
@kjvalencik kjvalencik merged commit 4730ab7 into main Jan 5, 2021
@kjvalencik kjvalencik deleted the kv/threadsafe-handles branch January 5, 2021 14:56
@demurgos
Copy link

demurgos commented Jan 8, 2021

Thank you very much for merging this PR!
I tried it out last week and it was great: it allowed me to completely switch to the N-API runtime and simplify my code.

I hope it will be released soon 🙂

It got released two days ago! Thank you!

@kjvalencik
Copy link
Member Author

@demurgos Yep! It's on 0.7.0 behind the event-queue-api feature flag. It requires at least napi-4.

neon = { version = "0.7", default-features = false, features = ["napi-4", "event-queue-api"] }

It's behind an additional feature flag because the API won't be considered stable until the RFC is merged.

Here are the API docs: https://docs.rs/neon/0.7.0-napi.3/neon/event/struct.EventQueue.html

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.

None yet

3 participants