Summary
It is quite astonishing that the same ownership principle that prevents memory safety violations in single-threaded contexts also works for multithreaded contexts in composition with marker traits. Rust has easy and safe ergonomics for integrating concurrrency in your application with minimal runtime cost. In this chapter, we learned how to use the threads
API provided by Rust's standard library and got to know how copy and move types work in the context of concurrency. We covered channels, the atomic reference counting type, Arc
, and how to use Arc
with Mutex
and also explored the actor model of concurrency.
In the next chapter, we'll dive into metaprogramming which is all about generating code from code.