Multithreading crates
Until now, we have only been using the standard library to manipulate threads, but thanks to the great crates.io ecosystem, we can make use of more approaches that will improve our development speed as well as the performance of our code.
Non-blocking data structures
One of the issues we saw earlier was that if we wanted to share something more complex than an integer or a Boolean between threads and if we wanted to mutate it, we needed to use a Mutex
. This is not entirely true, since one crate, Crossbeam, allows us to use great data structures that do not require locking a Mutex
. They are therefore much faster and more efficient.
Often, when we want to share information between threads, it's usually a list of tasks that we want to work on cooperatively. Other times, we want to create information in multiple threads and add it to a list of information. It's therefore not so usual for multiple threads to be working with exactly the same variables, since as we have seen...