- Preface
- What Is Async Rust?
- Who Is This Book For?
- Overview of the Chapters
- Conventions Used in This Book
- O’Reilly Online Learning
- How to Contact Us
- Acknowledgments
- Maxwell
- Caroline
- 1. Introduction to Async
- What Is Async?
- Introduction to Processes
- What Are Threads?
- Where Can We Utilize Async?
- Using Async for File I/O
- Improving HTTP Request Performance with Async
- Summary
- 2. Basic Async Rust
- Understanding Tasks
- Futures
- Pinning in Futures
- Context in Futures
- Waking Futures Remotely
- Sharing Data Between Futures
- High-Level Data Sharing Between Futures
- How Are Futures Processed?
- Putting It All Together
- Summary
- 3. Building Our Own Async Queues
- Building Our Own Async Queue
- Increasing Workers and Queues
- Passing Tasks to Different Queues
- Task Stealing
- Refactoring Our spawn_task Function
- Creating Our Own Join Macro
- Configuring Our Runtime
- Running Background Processes
- Summary
- 4. Integrating Networking into
Our Own Async Runtime
- Understanding Executors and Connectors
- Integrating hyper into Our Async Runtime
- Building an HTTP Connection
- Implementing the Tokio AsyncRead Trait
- Implementing the Tokio AsyncWrite Trait
- Connecting and Running Our Client
- Introducing mio
- Polling Sockets in Futures
- Sending Data over the Socket
- Summary
- 5. Coroutines
- Introducing Coroutines
- What Are Coroutines?
- Why Use Coroutines?
- Generating with Coroutines
- Implementing a Simple Generator in Rust
- Stacking Our Coroutines
- Calling a Coroutine from a Coroutine
- Mimicking Async Behavior with Coroutines
- Controlling Coroutines
- Testing Coroutines
- Summary
- 6. Reactive Programming
- Building a Basic Reactive System
- Defining Our Subjects
- Building Our Display Observer
- Building Our Heater and Heat-Loss Observer
- Getting User Input via Callbacks
- Enabling Broadcasting with an Event Bus
- Building Our Event Bus Struct
- Building Our Event Bus Handle
- Interacting with Our Event Bus via Async Tasks
- Summary
- 7. Customizing Tokio
- Building a Runtime
- Processing Tasks with Local Pools
- Getting Unsafe with Thread Data
- Graceful Shutdowns
- Summary
- 8. The Actor Model
- Building a Basic Actor
- Working with Actors Versus Mutexes
- Implementing the Router Pattern
- Implementing State Recovery for Actors
- Creating Actor Supervision
- Summary
- 9. Design Patterns
- Building an Isolated Module
- Waterfall Design Pattern
- The Decorator Pattern
- The State Machine Pattern
- The Retry Pattern
- The Circuit-Breaker Pattern
- Summary
- 10. Building an Async Server with
No Dependencies
- Setting Up the Basics
- Building Our std Async Runtime
- Building Our Waker
- Building Our Executor
- Running Our Executor
- Building Our Sender
- Building Our Receiver
- Building Our Sleep
- Building Our Server
- Accepting Requests
- Handling Requests
- Building Our Async Client
- Summary
- 11. Testing
- Performing Basic Sync Testing
- Mocking Async Code
- Testing For Deadlocks
- Testing for Race Conditions
- Testing Channel Capacity
- Testing Network Interactions
- Fine-Grained Future Testing
- Summary
- Index
- About the Authors