Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Concurrency with Rust

You're reading from   Hands-On Concurrency with Rust Confidently build memory-safe, parallel, and efficient software in Rust

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788399975
Length 462 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Brian L. Troutwine Brian L. Troutwine
Author Profile Icon Brian L. Troutwine
Brian L. Troutwine
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Preliminaries – Machine Architecture and Getting Started with Rust FREE CHAPTER 2. Sequential Rust Performance and Testing 3. The Rust Memory Model – Ownership, References and Manipulation 4. Sync and Send – the Foundation of Rust Concurrency 5. Locks – Mutex, Condvar, Barriers and RWLock 6. Atomics – the Primitives of Synchronization 7. Atomics – Safely Reclaiming Memory 8. High-Level Parallelism – Threadpools, Parallel Iterators and Processes 9. FFI and Embedding – Combining Rust and Other Languages 10. Futurism – Near-Term Rust 11. Other Books You May Enjoy

What this book covers

The material that this book covers is very broad, and it attempts to go into that material at some depth. The material is written so that you can work straight through, but it's also expected that some readers will only be interested in a subset of the content.

Chapter 1, Preliminaries – Machine Architecture and Getting Started with Rust, discusses modern CPU architectures, focusing specifically on x86 and ARM. These two architectures will be the focus of the book. The reader is assumed to be familiar with Rust, but we will also discuss verifying that your installation works as expected.

Chapter 2, Sequential Rust Performance and Testing, introduces inspecting the performance of a Rust program. The details of the underlying computer hardware are especially important in this: cache interactions, memory layout, and exploiting the nature of the problem domain are key to writing fast programs. However, fast doesn't matter if the results are inaccurate. This chapter also focuses on testing in Rust.

Chapter 3, The Rust Memory Model – Ownership, References and Manipulation, discusses the memory model of Rust, focusing specifically on what makes Rust memory safe, how the language is constrained to achieve such safety and how these constraints influence the fundamental types' implementations. The reader will understand the borrow checker and its ways at the close of this chapter.

Chapter 4, Sync and Send – the Foundation of Rust Concurrency, is the first in which notions of concurrency make their appearance. The chapter discusses the Sync and Send traits, both why they exist and their implications. The chapter closes with a concrete demonstration of a multithreaded Rust program. Not the last, either.

Chapter 5, Locks – Mutex, Condvar, Barriers and RWLock, introduces the coarse synchronization methods available to the Rust programmer. Each is examined in turn and demonstrated in context of an industrial Rust project, hopper. The coarse synchronization methods are elaborated on in more detail in a series of smaller projects and data structures.

Chapter 6, Atomics – the Primitives of Synchronization, introduces fine synchronization in terms of atomic primitives available on all modern CPUs. This is an exceedingly difficult topic, and a deep investigation into atomic programming and its methods is carried out. The chapter lock-free, atomic data structures, and production-grade codebases. The reader will construct many of the coarse synchronization mechanisms seen in Chapter 5, Locks – Mutex, Condvar, Barriers and RWLock.

Chapter 7, Atomics – Safely Reclaiming Memory, discusses at length one of the key difficulties of atomic programming in any language—safely deallocating memory. The main three methods—reference counting, hazard pointers, epoch-based reclamation—are each discussed in great detail, and production-worthy codebases are investigated. Crossbeam, especially, is discussed in great detail.

Chapter 8, High-Level Parallelism – Threadpools, Parallel Iterators and Processes, motivates and explains the implementation of thread pooling. Having this knowledge in hand, the Rayon project is investigated and subsequently used in a complex project that benefits greatly from simple data parallelism.

Chapter 9, FFI and Embedding – Combining Rust and Other Languages, extends the final project of Chapter 8, High-Level Parallelism – Threadpools, Parallel Iterators, and Processes by embedding C code into it. The rlua project, a convenient library to extend Rust programs with lua programs, is discussed. The chapter closes by compiling Rust for embedding into C, Python, and Erlang projects.

Chapter 10, Futurism – Near-Term Rust, closes the book with a discussion of the near-term changes to the language that are apropos to parallel programmers, as well as a few miscellaneous remarks.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image