Runtimes, Wakers, and the Reactor-Executor Pattern 196 The Executor struct is very simple, and there is only one line of code to add: ch08/b-reactor-executor/src/runtime/executor. rs pub struct Executor; Since all the state we need for our example is held in Executor Core, which is a static thread-local variable, our Executor struct doesn't need any state. This also means that we don't strictly need a struct at all, but to keep the API somewhat familiar, we do it anyway. Most of the executor implementation is a handful of simple helper methods that end up in a block_on function, which is where the interesting parts really happen. Since these helper methods are short and easy to understand, I'll present them all here and just briefly go over what they do: Note We open the impl Executor block here but will not close it until we've finished implementing the block_on function. ch08/b-reactor-executor/src/runtime/executor. rs impl Executor { pub fn new()-> Self { Self {} } fn pop_ready(&self)-> Option<usize> { CURRENT_EXEC. with(|q| q. ready_queue. lock(). map(|mut q| q. pop()). unwrap()) } fn get_future(&self, id: usize)-> Option<Task> { CURRENT_EXEC. with(|q| q. tasks. borrow_mut(). remove(&id)) } fn get_waker(&self, id: usize)-> Waker { Waker { id, thread: thread::current(), ready_queue: CURRENT_EXEC. with(|q| q. ready_queue. clone()), } }