Table of Contents ix Part 2: Event Queues and Green Threads 4 Create Your Own Event Queue 65 Technical requirements 65 Design and introduction to epoll 66 Is all I/O blocking? 72 The ffi module 73 Bitflags and bitmasks 76Level-triggered versus edge-triggered events 78 The Poll module 81 The main program 84 Summary 93 5 Creating Our Own Fibers 95 Technical requirements 96 How to use the repository alongside the book 96 Background information 97 Instruction sets, hardware architectures, and ABIs 97 The System V ABI for x86-64 99 A quick introduction to Assembly language 102 An example we can build upon 103 Setting up our project 103 An introduction to Rust inline assembly macro 105Running our example 107 The stack 109 What does the stack look like? 109 Stack sizes 111 Implementing our own fibers 112 Implementing the runtime 115 Guard, skip, and switch functions 121 Finishing thoughts 125 Summary 126 Part 3: Futures and async/await in Rust 6 Futures in Rust 129 What is a future? 130 Leaf futures 130Non-leaf futures 130 A mental model of an async runtime 131