-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
perf(ext/napi): port NAPI to v8 tasks #21406
Conversation
@littledivy This one seems to be working, but I need a bit of help coming up with a test plan to make sure that it works as expected. Do you know of a good npm package to test it with? |
@mmastrac https://www.npmjs.com/package/@parcel/watcher is a good one for testing thread safe functions. |
#[repr(transparent)] | ||
struct SendPtr<T>(*const T); | ||
unsafe impl<T> Send for SendPtr<T> {} | ||
unsafe impl<T> Sync for SendPtr<T> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SendPtr from cli/napi/async.rs can be reused here?
context: SendPtr<c_void>, | ||
data: SendPtr<c_void>, | ||
) { | ||
// SAFETY: We're calling the provided callback with valid args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
); | ||
|
||
fn event_loop_middleware( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Co-authored-by: Divy Srivastava <[email protected]> Signed-off-by: Matt Mastracci <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pending review items from #21406
Part 2 of removing middleware.
This is somewhat awkward because
V8CrossThreadTaskSpawner
requires tasks to beSend
, but NAPI makes heavy use of!Send
pointers. In addition, Rust causes a closure to be!Send
if you pull a!Send
value out of a struct.