Improving our base example 179 Self { poll } } pub fn block_on<F>(&mut self, future: F) where F: Future<Output = String>, { let mut future = future; loop { match future. poll() { Poll State::Not Ready => { println!("Schedule other tasks\n"); let mut events = Events::with_capacity(100); self. poll. poll(&mut events, None). unwrap(); } Poll State::Ready(_) => break, } } } } The first thing we do is create a new function. This will initialize our runtime and set everything we need up. We create a new Poll instance, and from the Poll instance, we get an owned version of Registry. If you remember from Chapter 4, this is one of the methods we mentioned but didn't implement in our example. However, here, we take advantage of the ability to split the two pieces up. We store Registry in the REGISTRY global variable so that we can access it from the http module later on without having a reference to the runtime itself. The next function is the block_on function. I'll go through it step by step: 1. First of all, this function takes a generic argument and will block on anything that implements our Future trait with an Output type of String (remember that this is currently the only kind of Future trait we support, so we'll just return an empty string if there is no data to return). 2. Instead of having to take mut future as an argument, we define a variable that we declare as mut in the function body. It's just to keep the API slightly cleaner and avoid us having to make minor changes later on. 3. Next, we create a loop. We'll loop until the top-level future we received returns Ready. If the future returns Not Ready, we write out a message letting us know that at this point we could do other things, such as processing something unrelated to the future or, more likely, polling another top-level future if our runtime supported multiple top-level futures (don't worry-it will be explained later on).