January 2019
Beginner to intermediate
554 pages
13h 31m
English
Thread-safety is the idea that, if you have data that you want to data from multiple threads, any read or write operation on that value does not lead to inconsistent results. The problem with updating a value, even with a simple increment operation such as a += 1 is that it roughly translates in to a three-step process—load increment store. Data that can be safely updated is meant to be wrapped in thread-safe types such as Arc and Mutex to ensure that we have data consistency in a program.
In Rust, you get compile-time guarantees on types that can be safely used and referenced within a thread. These guarantees are implemented as traits, which are the Send and Sync trait.
Read now
Unlock full access