-
Notifications
You must be signed in to change notification settings - Fork 287
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
Neon + Tokio Thread Pool #215
Comments
Yep, the error is telling the truth. Deep down the Neon representation of the V8 isolate is a Do checkout the wonderful work in #214 though. Once that lands, we'll get proper background work off the main thread. If you don't need async callbacks, but just want to parallelize the work you're doing that is possible today. The home page of neon-bindings.com shows that you can use Rayon this way. lines.into_par_iter() // iterate in parallel
.map(|line| wc(line, word)) // count words for each
.sum() // calculate the total The full word counting example is a bit old and I'm not sure if it's compatible with the latest Neon, nonetheless you can find it here: https://github.com/dherman/wc-demo I hope that helps. |
Thanks for the answer. I did notice #214 before but since it was not yet available, I decided to try something using Tokio crate. The async callbacks are required as a conduit to resolve a JavaScript side promise: function encryptAsync(decrypted, rsaKey) {
return new Promise((resolve, reject) => {
addon.encryptAndNotify(decrypted, rsaKey, (result) => resolve(cloneString(result)) );
})
} |
Yes, I'm afraid this is not something you can do; JS values and APIs can only be accessed from the main thread. We are investigating the possibility of more general threading APIs than the task API, so hopefully you'll be able to do more and more things with threads. But it will always be the case that JS operations are only on the main thread. |
Hi!
I'm getting the following error:
And here's the code:
I'm really new to rust and I sure that I'm missing something. No idea what though :(
The text was updated successfully, but these errors were encountered: