[Connect] Migrate to tokio 0.1

This commit is contained in:
ashthespy 2021-01-23 22:21:42 +00:00
parent 53b4ab05ba
commit c69ccf77e9
3 changed files with 9 additions and 10 deletions

View file

@ -28,7 +28,7 @@ rand = "0.7"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
tokio-core = "0.1" tokio = "0.1"
url = "1.7" url = "1.7"
sha-1 = "0.8" sha-1 = "0.8"
hmac = "0.7" hmac = "0.7"
@ -38,6 +38,7 @@ block-modes = "0.3"
dns-sd = { version = "0.1.3", optional = true } dns-sd = { version = "0.1.3", optional = true }
libmdns = { version = "0.2.7", optional = true } libmdns = { version = "0.2.7", optional = true }
[features] [features]
default = ["libmdns"] default = ["libmdns"]
with-dns-sd = ["dns-sd"] with-dns-sd = ["dns-sd"]

View file

@ -22,7 +22,7 @@ use rand;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io; use std::io;
use std::sync::Arc; use std::sync::Arc;
use tokio_core::reactor::Handle; use tokio::runtime::current_thread::Handle;
use url; use url;
use librespot_core::authentication::Credentials; use librespot_core::authentication::Credentials;
@ -235,11 +235,9 @@ pub fn discovery(
let serve = { let serve = {
let http = Http::new(); let http = Http::new();
http.serve_addr_handle( http.serve_addr(&format!("0.0.0.0:{}", port).parse().unwrap(), move || {
&format!("0.0.0.0:{}", port).parse().unwrap(), Ok(discovery.clone())
handle.new_tokio_handle(), })
move || Ok(discovery.clone()),
)
.unwrap() .unwrap()
}; };
@ -254,13 +252,13 @@ pub fn discovery(
hyper::server::conn::AddrStream, hyper::server::conn::AddrStream,
futures::Failed<_, hyper::Error>, futures::Failed<_, hyper::Error>,
>| { >| {
handle.spawn(connecting.then(|_| Ok(()))); handle.spawn(connecting.flatten().then(|_| Ok(()))).unwrap();
Ok(()) Ok(())
}, },
) )
.then(|_| Ok(())) .then(|_| Ok(()))
}; };
handle.spawn(server_future); handle.spawn(server_future).unwrap();
#[cfg(feature = "with-dns-sd")] #[cfg(feature = "with-dns-sd")]
let svc = DNSService::register( let svc = DNSService::register(

View file

@ -12,7 +12,7 @@ extern crate hyper;
extern crate num_bigint; extern crate num_bigint;
extern crate protobuf; extern crate protobuf;
extern crate rand; extern crate rand;
extern crate tokio_core; extern crate tokio;
extern crate url; extern crate url;
extern crate aes_ctr; extern crate aes_ctr;