Asynchronous Programming in Rust: Learn asynchronous programming by building working examples of futures, green threads, and runtimes 1st Edition by Carl Fredrik Samson – Ebook PDF Instant Download/DeliveryISBN: 1805126621, 9781805126621
Full download Asynchronous Programming in Rust: Learn asynchronous programming by building working examples of futures, green threads, and runtimes 1st Edition after payment.

Product details:
ISBN-10 : 1805126621
ISBN-13 : 9781805126621
Author: Carl Fredrik Samson
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.
Asynchronous Programming in Rust: Learn asynchronous programming by building working examples of futures, green threads, and runtimes 1st Table of contents:
Part 1:Asynchronous Programming Fundamentals
Chapter 1: Concurrency and Asynchronous Programming: a Detailed Overview
Technical requirements
An evolutionary journey of multitasking
Non-preemptive multitasking
Preemptive multitasking
Hyper-threading
Multicore processors
Do you really write synchronous code?
Concurrency versus parallelism
The mental model I use
Let’s draw some parallels to process economics
Concurrency and its relation to I/O
What about threads provided by the operating system?
Choosing the right reference frame
Asynchronous versus concurrent
The role of the operating system
Concurrency from the operating system’s perspective
Teaming up with the operating system
Communicating with the operating system
The CPU and the operating system
Down the rabbit hole
How does the CPU prevent us from accessing memory we’re not supposed to access?
But can’t we just change the page table in the CPU?
Interrupts, firmware, and I/O
A simplified overview
Interrupts
Firmware
Summary
Chapter 2: How Programming Languages Model Asynchronous Program Flow
Definitions
Threads
Threads provided by the operating system
Creating new threads takes time
Each thread has its own stack
Context switching
Scheduling
The advantage of decoupling asynchronous operations from OS threads
Example
Fibers and green threads
Each stack has a fixed space
Context switching
Scheduling
FFI
Callback based approaches
Coroutines: promises and futures
Coroutines and async/await
Summary
Chapter 3: Understanding OS-Backed Event Queues, System Calls, and Cross-Platform Abstractions
Technical requirements
Running the Linux examples
Why use an OS-backed event queue?
Blocking I/O
Non-blocking I/O
Event queuing via epoll/kqueue and IOCP
Readiness-based event queues
Completion-based event queues
epoll, kqueue, and IOCP
Cross-platform event queues
System calls, FFI, and cross-platform abstractions
The lowest level of abstraction
The next level of abstraction
The highest level of abstraction
Summary
Part 2:Event Queues and Green Threads
Chapter 4: Create Your Own Event Queue
Technical requirements
Design and introduction to epoll
Is all I/O blocking?
The ffi module
Bitflags and bitmasks
Level-triggered versus edge-triggered events
The Poll module
The main program
Summary
Chapter 5: Creating Our Own Fibers
Technical requirements
How to use the repository alongside the book
Background information
Instruction sets, hardware architectures, and ABIs
The System V ABI for x86-64
A quick introduction to Assembly language
An example we can build upon
Setting up our project
An introduction to Rust inline assembly macro
Running our example
The stack
What does the stack look like?
Stack sizes
Implementing our own fibers
Implementing the runtime
Guard, skip, and switch functions
Finishing thoughts
Summary
Part 3:Futures and async/await in Rust
Chapter 6: Futures in Rust
What is a future?
Leaf futures
Non-leaf futures
A mental model of an async runtime
What the Rust language and standard library take care of
I/O vs CPU-intensive tasks
Summary
Chapter 7: Coroutines and async/await
Technical requirements
Introduction to stackless coroutines
An example of hand-written coroutines
Futures module
HTTP module
Do all futures have to be lazy?
Creating coroutines
async/await
coroutine/wait
corofy—the coroutine preprocessor
b-async-await—an example of a coroutine/wait transformation
c-async-await—concurrent futures
Final thoughts
Summary
Chapter 8: Runtimes, Wakers, and the Reactor-Executor Pattern
Technical requirements
Introduction to runtimes and why we need them
Reactors and executors
Improving our base example
Design
Changing the current implementation
Creating a proper runtime
Step 1 – Improving our runtime design by adding a Reactor and a Waker
Creating a Waker
Changing the Future definition
Step 2 – Implementing a proper Executor
Step 3 – Implementing a proper Reactor
Experimenting with our new runtime
An example using concurrency
Running multiple futures concurrently and in parallel
Summary
Chapter 9: Coroutines, Self-Referential Structs, and Pinning
Technical requirements
Improving our example 1 – variables
Setting up the base example
Improving our base example
Improving our example 2 – references
Improving our example 3 – this is… not… good…
Discovering self-referential structs
What is a move?
Pinning in Rust
Pinning in theory
Definitions
Pinning to the heap
Pinning to the stack
Pin projections and structural pinning
Improving our example 4 – pinning to the rescue
future.rs
http.rs
Main.rs
executor.rs
Summary
Chapter 10: Creating Your Own Runtime
Technical requirements
Setting up our example
main.rs
future.rs
http.rs
executor.rs
reactor.rs
Experimenting with our runtime
Challenges with asynchronous Rust
Explicit versus implicit reactor instantiation
Ergonomics versus efficiency and flexibility
Common traits that everyone agrees about
Async drop
The future of asynchronous Rust
Summary
Epilogue
People also search for Asynchronous Programming in Rust: Learn asynchronous programming by building working examples of futures, green threads, and runtimes 1st:
asynchronous programming in rust github
asynchronous programming in rust packt
asynchronous programming in rust amazon
asynchronous programming in rust samson
asynchronous programming in rust reddit
Tags: Asynchronous Programming, Rust, asynchronous, working examples, green threads, Carl Fredrik Samson


