January 2019
Beginner to intermediate
554 pages
13h 31m
English
Threads can also communicate with each other through a more high level abstraction called message passing. This model of thread communication removes the need to use explicit locks by the user.
The standard library's std::sync::mpsc module provides a lock-free multi-producer, single-subscriber queue, which serves as a shared message queue for threads wanting to communicate with one another. The mpsc module standard library has two kinds of channels:
Channels can be used to send data from one thread to another. Let's look at asynchronous channels first.
Read now
Unlock full access