Asynchronous Programming in Rust Learn asynchronous programming by building working examples of futures, green threads, and… (Carl Fredrik Samson)(Z-Library)
Get a fundamental understanding of asynchronous programming and Rust's futures by working through examples that show you how everything really works
Key Features
- Master asynchronous Rust through examples focusing on key concepts
- Build a solid understanding of concepts such as coroutines, fibers, futures, and callbacks
- Explore Rust's futures, craft your own runtime, and excel in handling stacks, ABIs, syscalls, and inline assembly
Book Description
Step into the world of asynchronous programming with confidence by conquering the challenges of unclear concepts with this hands-on guide. Using functional examples, this book simplifies the trickiest concepts, exploring goroutines, fibers, futures, and callbacks to help you navigate the vast Rust async ecosystem with ease.
You'll start by building a solid foundation in asynchronous programming and explore diverse strategies for modeling program flow. The book then guides you through concepts like epoll, coroutines, green threads, and callbacks using practical examples. The final section focuses on Rust, examining futures, generators, and the reactor-executor pattern. You'll apply your knowledge to create your own runtime, solidifying expertise in this dynamic domain. Throughout the book, you'll not only gain proficiency in Rust's async features but also see how Rust models asynchronous program flow.
By the end of the book, you'll possess the knowledge and practical skills needed to actively contribute to the Rust async ecosystem.
Who this book is for
This book is for programmers who want to enhance their understanding of asynchronous programming, especially those experienced in VM'ed or interpreted languages like C#, Java, Python, JavaScript, and Go. If you work with C or C++ but have had limited exposure to asynchronous programming, this book serves as a resource to broaden your knowledge in this area. …
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on guide that demystifies asynchronous programming by building it from the ground up—from OS event queues and green threads to Rust's futures and a working runtime—for developers who want to understand *why* async works, not just how to call it.
【Book Arc】
- **Opening (~0%–10%)**: Frames the whole project—concurrency vs. parallelism, why I/O-bound work motivates async, and how to set up the companion code repository crate by crate.
- **Early (~10%–35%)**: Builds the conceptual vocabulary: threads (OS vs. user-level), stackful vs. stackless tasks, callbacks, and readiness-based event queues like epoll/kqueue and IOCP, with their trade-offs.
- **Middle (~35%–55%)**: Moves into systems-level practice—raw syscalls from Rust, FFI and error handling, calling conventions, stacks, and assembly—then implements a custom event queue modeled on mio and explores fibers/green threads à la Go.
- **Late (~55%–85%)**: Turns to Rust specifically: futures, generators, and the reactor–executor pattern, culminating in building a runtime with a Reactor and Waker.
- **Ending (~85%–100%)**: Refines the runtime to run multiple futures concurrently and in parallel, then summarizes how the pieces fit together.
【Key Takeaways】
- **Concurrency is about working smarter; parallelism is throwing more resources at the problem** (Early): this distinction anchors every later design choice, especially why async pays off for I/O but not pure computation.
- **Stackful vs. stackless is the key axis for async models** (Early): stackful tasks (fibers) preserve a full call stack and can suspend anywhere; stackless tasks (Rust futures) share one stack and are cheaper to switch but can't suspend mid-frame.
- **Callbacks are easy to implement but hard to reason about** (Early): memory grows linearly with callback count, ownership becomes painful without a GC, and rewriting sequential code is a substantial effort—hence "callback hell."
- **Readiness-based event queues (epoll/kqueue) let one thread watch thousands of handles cheaply** (Middle): you register interest, block on a wait call, and get woken when events are ready—the foundation mio abstracts over.
- **Cross-platform async requires wrestling with syscalls, ABIs, and calling conventions** (Middle): the book shows raw `write` on Linux versus Windows API handles, plus FFI error handling, to explain why abstractions like mio exist.
- **Rust's async is built on futures, generators, and the reactor–executor pattern** (Late): understanding these separately makes the runtime implementation feel inevitable rather than magical.
- **A Waker is what connects the reactor to the executor** (Late): building one by hand clarifies how a future gets polled again when its event fires.
- **Writing your own runtime cements the mental model** (Ending): running multiple futures concurrently and in parallel turns abstract concepts into working code you can debug.
【Reading Tips】
- **Read with a code editor and the GitHub repo open side by side**—the book explicitly recommends typing examples rather than copy-pasting, and each example is a separate crate ordered by letter prefix.
- **Deep-read Part 1 (concurrency fundamentals and event queues)** even if you think you know async; the stackful/stackless and callback trade-off framing pays off throughout.
- **Skim the assembly/ABI/syscall sections on a first pass** if you're not a systems programmer—return to them when building the fiber and runtime chapters, where they matter most.
- **On Windows, enable WSL** before the syscall and epoll chapters; several examples assume a Unix-like environment.
- **Take away the reactor–executor–Waker loop as your mental model**—if you can sketch it from memory after the runtime chapters, you've got the book's core.
【Coverage Limits】
These excerpts cover the book's structure, preface, and early-to-middle conceptual chapters well, but the late runtime implementation details (Reactor, Waker, parallel execution) are only glimpsed through the table of contents and summaries; specific code walkthroughs there are not represented.
Excerpt 1
rpreted languages like C#, Java, Python, JavaScript, and Go. If you work with C or C++ but have had limited exposure to asynchronous programming, this book s...
s a task. However, you have many tasks to do so instead of waiting, you continue to work elsewhere and either check in regularly to see whether the task is r...
le demonstrates the creation of an event queue using epoll. We will design the API to closely resemble the one used by mio, allowing us to grasp the fundamen...
es. The first thing we do is to create an ffi::Event object. The events field is simply set to the bitmask we received and named interests, and epoll_data is...
as one of many operations to complete the task. Summary 135 The third method is more of theoretical importance; normally, you’d be happy to send the task to...
machine through its different stages of the main function. 156 Coroutines and async/await of the main goals is to take a look at the differences between the...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Asynchronous Programming in Rust Learn asynchronous programming by building working examples of futures, green threads, and… (Carl Fredrik Samson)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
Asynchronous Programming in Rust Learn asynchronous programming by building working examples of futures, green threads, and… (Carl Fredrik Samson)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Asynchronous Programming in Rust Learn asynchronous programming by building working examples of futures, green threads, and… (Carl Fredrik Samson)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment