Step 3-Implementing a proper Reactor 203 let Token(id) = e. token(); let wakers = wakers. lock(). unwrap(); if let Some(waker) = wakers. get(&id) { waker. wake(); } } } } This function takes a Poll instance and a Wakers collection as arguments. Let's go through it step by step: The first thing we do is create an events collection. This should be familiar since we did the exact same thing in Chapter 4. The next thing we do is create a loop that in our case will continue to loop for eternity. This makes our example short and simple, but it has the downside that we have no way of shutting our event loop down once it's started. Fixing that is not especially difficult, but since it won't be necessary for our example, we don't cover this here. Inside the loop, we call Poll::poll with a timeout of None, which means it will never time out and block until it receives an event notification. When the call returns, we loop through every event we receive. If we receive an event, it means that something we registered interest in happened, so we get the id we passed in when we first registered an interest in events on this Tcp Stream. Lastly, we try to get the associated Waker and call Waker::wake on it. We guard ourselves from the fact that the Waker may have been removed from our collection already, in which case we do nothing. It's worth noting that we can filter events if we want to here. Tokio provides some methods on the Event object to check several things about the event it reported. For our use in this example, we don't need to filter events. Finally, the last function is the second public function in this module and the one that initializes and starts the runtime: ch08/b-reactor-executor/src/runtime/runtime. rs pub fn start() { use thread::spawn; let wakers = Arc::new(Mutex::new(Hash Map::new()));