message: Run trust-dns background resolving Future in current reactor
diff: //! Asynchronous DNS resolver
  use std::io::{self, ErrorKind};
  -use std::mem;
  use std::net::SocketAddr;
  use std::sync::Arc;
  use futures::Future;
  use spin::Mutex;
  -use tokio::runtime::current_thread::Runtime;
  +use tokio;
  use trust_dns_resolver::config::ResolverConfig;
  use trust_dns_resolver::AsyncResolver;
  @@ -33,21 +32,6 @@ fn get_dns_address() -> Option<ResolverConfig> {
  }
  fn init_resolver() -> AsyncResolver {
  - use std::sync::{Arc, Condvar, Mutex};
  - use std::thread;
  -
  - // We'll be using this condvar to get the Resolver from the thread...
  - let pair = Arc::new((Mutex::new(None::<AsyncResolver>), Condvar::new()));
  - let pair2 = pair.clone();
  -
  - // Spawn the runtime to a new thread...
  - //
  - // This thread will manage the actual resolution runtime
  - thread::spawn(move || {
  - // A runtime for this new thread
  - let mut runtime = Runtime::new().expect("failed to launch Runtime");
  -
  - // our platform independent future, result, see next blocks
  let (resolver, bg) = {
  // To make this independent, if targeting macOS, BSD, Linux, or Windows, we can use the system's configuration:
  #[cfg(any(unix, windows))]
  @@ -78,27 +62,10 @@ fn init_resolver() -> AsyncResolver {
  }
  };
  - let &(ref lock, ref cvar) = &*pair2;
  - let mut started = lock.lock().unwrap();
  - *started = Some(resolver);
  - cvar.notify_one();
  - drop(started);
  -
  - runtime.block_on(bg).expect("Failed to create DNS resolver");
  - });
  -
  - // Wait for the thread to start up.
  - let &(ref lock, ref cvar) = &*pair;
  - let mut resolver = lock.lock().unwrap();
  - while resolver.is_none() {
  - resolver = cvar.wait(resolver).unwrap();
  - }
  -
  - // take the started resolver
  - let resolver = mem::replace(&mut *resolver, None);
  + // NOTE: resolving will always be called inside a future.
  + tokio::spawn(bg);
  - // set the global resolver
  - resolver.expect("resolver should not be none")
  + resolver
  }
  fn inner_resolve(config: Arc<Config>,
  