Concurrency

Modern day software is rarely written to perform tasks sequentially. It is more important today to be able to write programs that do more than one thing at a time and do it correctly. As transistors keep getting smaller, computer architects are unable to scale CPU clocks frequency due to quantum effects in the transistors. This has shifted focus more towards building concurrent CPU architectures that employ multiple cores. With this shift, developers need to write highly concurrent applications to maintain performance gains that they had for free when Moore's law was in effect.

But writing concurrent code is hard and languages that don't provide better abstractions make the situation worse. Rust attempts to make things better and safer in this space. In this chapter, we will go through the concepts and primitives that enable Rust to provide fearless concurrency to developers, allowing them to easily express their programs in a way that can safely do more than one thing at a time.

The topics covered in this chapter are as follows:

  • Program execution models
  • Concurrency and associated pitfalls
  • Threads as unit of concurrency
  • How Rust provides thread-safety
  • Concurrency primitives in Rust
  • Other libraries for concurrency

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset