Runtimes, Wakers, and the Reactor-Executor Pattern 202 self. registry. deregister(stream). unwrap(); } pub fn next_id(&self)-> usize { self. next_id. fetch_add(1, Ordering::Relaxed) } } Let's briefly explain what these four methods do: register -This method is a thin wrapper around Registry::register, which we know from Chapter 4. The one thing to make a note of here is that we pass in an id property so that we can identify which event has occurred when we receive a notification later on. set_waker -This method adds a Waker to our Hash Map using the provided id property as a key to identify it. If there is a Waker there already, we replace it and drop the old one. An important point to remember is that we should always store the most recent Waker so that this function can be called multiple times, even though there is already a Waker associated with the Tcp Stream. deregister -This function does two things. First, it removes the Waker from our wakers collection. Then, it deregisters the Tcp Stream from our Poll instance. I want to remind you at this point that while we only work with Tcp Stream in our examples, this could, in theory, be done with anything that implements mio 's Source trait, so the same thought process is valid in a much broader context than what we deal with here. next_id -This simply gets the current next_id value and increments the counter atomically. We don't care about any happens before/after relationships happening here; we only care about not handing out the same value twice, so Ordering::Relaxed will suffice here. Memory ordering in atomic operations is a complex topic that we won't be able to dive into in this book, but if you want to know more about the different memory orderings in Rust and what they mean, the official documentation is the right place to start: https://doc. rust-lang. org/stable/std/sync/atomic/enum. Ordering. html. Now that our Reactor is set up, we only have two short functions left. The first one is event_loop, which will hold the logic for our event loop that waits and reacts to new events: ch08/b-reactor-executor/src/runtime/reactor. rs fn event_loop(mut poll: Poll, wakers: Wakers) { let mut events = Events::with_capacity(100); loop { poll. poll(&mut events, None). unwrap(); for e in events. iter() {