A good and clear documentation about Threading with rust?

Hello,
Could you advice me for a link to a complete and clear documentation (or a book) about Threading in Rust (using rayon or tokio or other) ?

I'm guessing you're asking about concurrency as well as threads, since you mentioned tokio.

If you haven't gone through it already, I recommend the Fearless Concurrency section of "the book" to start with.

I don't have any recommendations for something more complete, but for that you probably need to decide whether you want to study threads or async, since they're quite different. If you want to study async, there is the Async Book.

2 Likes

Be aware that there is a big difference between threading as in Rust std::thread: std::thread - Rust or rayon:rayon - Rust and asynchronous tasks as in Tokio https://tokio.rs.

I like to think of it as:
Use threading when you have a lot of computation to do and could get a performance boost by using multiple processors/cores.
Use async when you have a lot jobs that don't require lots of compute time but do a lot of waiting on lots of I/O.

In short, Threads for work, async for waiting.

Let us know if the docs linked above raise questions for you.

6 Likes

Thanks @jumpnbrownweasel and @ZiCog !
In addition I'm searching for documentation with different complete use cases and complete codes.

For normal threading (using the std::thread package and related crates)? Or async (using the async and await keywords and an executor crate such as tokio)?

Reading materials for these two things are generally separate. If you don't know the difference between them, refer to @ZiCog 's post above and ask any further questions you have.

ok thanks you !

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.