Skip to content
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

DRAFT: "async_local" feature for local-thread Rust futures #2154

Closed

Conversation

alshdavid
Copy link

@alshdavid alshdavid commented Jun 23, 2024

This PR adds the ability to use the local thread to manage concurrency allowing for faster and more ergonomic syntax

Changelog

  • async_local feature
  • adds env.spawn_local
  • adds JsRc

Usage:

#[napi]
pub fn run_callback(env: Env, callback: JsFunction,
) -> napi::Result<JsUndefined> {
  let callback = callback.into_ref()?;

  env.spawn_local(move |env| async move {
    let callback = callback.clone(&env).unwrap();
    callback.call_without_args(None).unwrap();
  });

  env.get_undefined()
}

For more details see Github RFC here

@alshdavid
Copy link
Author

Moved to here
#2158

@alshdavid alshdavid closed this Jun 25, 2024
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

1 participant