Runtimes, Wakers, and the Reactor-Executor Pattern 178 The next step is to create a static variable called REGISTRY. If you remember, Registry is the way we register interest in events with our Poll instance. We want to register interest in events on our Tcp Stream when making the actual HTTP GET request. We could have Http::get accept a Registry struct that it stored for later use, but we want to keep the API clean, and instead, we want to access Registry inside Http Get Future without having to pass it around as a reference: ch08/a-runtime/src/runtime. rs static REGISTRY: Once Lock<Registry> = Once Lock::new(); pub fn registry()-> &'static Registry { REGISTRY. get(). expect("Called outside a runtime context") } We use std::sync::Once Lock so that we can initialize REGISTRY when the runtime starts, thereby preventing anyone (including ourselves) from calling Http::get without having a Runtime instance running. If we did call Http::get without having our runtime initialized, it would panic since the only public way to access it outside the runtime module is through the pub fn registry(){... } function, and that call would fail. Note We might as well have used a thread-local static variable using the thread_local! macro from the standard library, but we'll need to access this from multiple threads when we expand the example later in this chapter, so we start the design with this in mind. The next thing we add is a Runtime struct: ch08/a-runtime/src/runtime. rs pub struct Runtime { poll: Poll, } For now, our runtime will only store a Poll instance. The interesting part is in the implementation of Runtime. Since it's not too long, I'll present the whole implementation here and explain it next: ch08/a-runtime/src/runtime. rs impl Runtime { pub fn new()-> Self { let poll = Poll::new(). unwrap(); let registry = poll. registry(). try_clone(). unwrap(); REGISTRY. set(registry). unwrap();