Runtimes, Wakers, and the Reactor-Executor Pattern 204 let poll = Poll::new(). unwrap(); let registry = poll. registry(). try_clone(). unwrap(); let next_id = Atomic Usize::new(1); let reactor = Reactor { wakers: wakers. clone(), registry, next_id, }; REACTOR. set(reactor). ok(). expect("Reactor already running"); spawn(move || event_loop(poll, wakers)); } The start method should be fairly easy to understand. The first thing we do is create our Wakers collection and our Poll instance. From the Poll instance, we get an owned version of Registry. We initialize next_id to 1 (for debugging purposes, I wanted to initialize it to a different start value than our Executor ) and create our Reactor object. Then, we set the static variable we named REACTOR by giving it our Reactor instance. The last thing is probably the most important one to pay attention to. We spawn a new OS thread and start our event_loop function on that one. This also means that we pass on our Poll instance to the event loop thread for good. Now, the best practice would be to store the Join Handle returned from spawn so that we can join the thread later on, but our thread has no way to shut down the event loop anyway, so joining it later makes little sense, and we simply discard the handle. I don't know if you agree with me, but the logic here is not that complex when we break it down into smaller pieces. Since we know how epoll and mio work already, the rest is pretty easy to understand. Now, we're not done yet. We still have some small changes to make to our Http Get Future leaf future since it doesn't register with the reactor at the moment. Let's fix that. Start by opening the http. rs file. Since we already added the correct imports when we opened the file to adapt everything to the new Future interface, there are only a few places we need to change that so this leaf future integrates nicely with our reactor. The first thing we do is give Http Get Future an identity. It's the source of events we want to track with our Reactor, so we want it to have the same ID until we're done with it: ch08/b-reactor-executor/src/http. rs struct Http Get Future { stream: Option<mio::net::Tcp Stream>,