-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
chore(napi): Refactor async parsing functions to remove tokio dependency #4049
chore(napi): Refactor async parsing functions to remove tokio dependency #4049
Conversation
- Added `use napi::{bindgen_prelude::AsyncTask, Task}` to handle async tasks without tokio. - Introduced `ResolveTask` struct implementing `Task` for asynchronous parsing. - Replaced `parse_sync` function implementation with `parse_with_return` to reuse code. - Refactored `parse_async` to use `AsyncTask` and `ResolveTask` for async parsing. - Removed tokio dependency by avoiding `tokio::spawn` and using `AsyncTask` for async operations. This refactor enhances code readability and removes the dependency on tokio, streamlining the async task handling within the napi framework.
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
CodSpeed Performance ReportMerging #4049 will not alter performanceComparing Summary
|
|
Another part of the code also needs modification: oxc/napi/parser/src/module_lexer.rs Line 144 in e32b4bc
|
- Simplified parse_with_return function to eliminate unnecessary lifetime annotation and unnecessary borrowing of variables. - Updated span.source_text usage to directly reference parameters instead of borrowing.
- Changed module_lexer function parameters from String and Option<ParserOptions> to &str and &ParserOptions, using unwrap_or_default for the options parameter. - Updated module_lexer_sync function to call module_lexer with &source_text and &options. - Introduced napi::{bindgen_prelude::AsyncTask, Task}, and implemented the Task trait for the ResolveTask struct. - Added support for AsyncTask<ResolveTask> in the module_lexer_async function to handle asynchronous tasks.
Thank you! |
Resolves #4044
use napi::{bindgen_prelude::AsyncTask, Task}
to handle async tasks without tokio.ResolveTask
struct implementingTask
for asynchronous parsing.parse_sync
function implementation withparse_with_return
to reuse code.parse_async
to useAsyncTask
andResolveTask
for async parsing.tokio::spawn
and usingAsyncTask
for async operations.This refactor enhances code readability and removes the dependency on tokio, streamlining the async task handling within the napi framework.