3 ms·
> Unlike Node.js, Rust's Tokio allows us to spawn a new Task and run futures within it. Nice article! For future reference in Node.js this would be `worker_thr
by inglor 1y ago
> Unlike Node.js, Rust's Tokio allows us to spawn a new Task and run futures within it.
Nice article! For future reference in Node.js this would be `worker_threads` or if you want a higher level tokio like API something like https://piscinajs.dev/ https://piscinajs.dev/
This has been possible in Node.js for quite a while
--
Also for blocking I/O CPU bound parallelism I've found Rayon to be a pleasure. It has a few caveats but it leverages the Rust race condition checking well and it's very ergonomic.
I happily mix it with `tokio` in an application that is CPU bound but has to perform some async I/O (due to the SDKs it uses)
- remram 1y agoA tokio task is not a thread
- inglor 1y agoA node worker_thread is not a thread either though :]
- remram 1y agoReally? The docs make it seems like it is: https://nodejs.org/api/worker_threads.html#worker-threads https://nodejs.org/api/worker_threads.html#worker-threads
- cstrahan 1y agoRight at the top of the docs for worker_threads: > The node:worker_threads module enables the use of threads that execute JavaScript in parallel. Now that it doesn’t say “concurrent”, it says “parallel”. This implies that multiple threads are involved.
- SkiFire13 1y ago> piscinajs Lmao this wordplay made my day > Rust race condition checking Nit: Rust does not prevent race conditions, it prevents data races.