January 2019
Beginner to intermediate
554 pages
13h 31m
English
While Mutex is fine for most use cases, for some multi-threaded scenarios, reads happen more often than writes from multiple threads. In that case, we can use the RwLock type, which also provides shared mutability but can do so at a more granular level. RwLock stands for Reader-Writer lock. With RwLock, we can have many readers at the same but only one writer in a given scope. This is much better than a Mutex which agnostic of the kind of access a thread wants. Using RwLock
RwLock exposes two methods:
Here's a sample ...
Read now
Unlock full access