feat(rt): make tokio runtime optional
A Cargo feature `runtime` is added, which is enabled by default, that includes the following: - The `client::HttpConnector`, which uses `tokio::net::TcpStream`. - The `server::AddrStream`, which uses `tokio::net::TcpListener`. - The `hyper::rt` module, which includes useful utilities to work with the runtime without needing to import `futures` or `tokio` explicity. Disabling the feature removes many of these niceties, but allows people to use hyper in environments that have an alternative runtime, without needing to download an unused one.
This commit is contained in:
@@ -2,7 +2,6 @@ use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::future::{Executor, Future};
|
||||
use tokio_executor::spawn;
|
||||
|
||||
/// Either the user provides an executor for background tasks, or we use
|
||||
/// `tokio::spawn`.
|
||||
@@ -19,7 +18,17 @@ impl Exec {
|
||||
F: Future<Item=(), Error=()> + Send + 'static,
|
||||
{
|
||||
match *self {
|
||||
Exec::Default => spawn(fut),
|
||||
Exec::Default => {
|
||||
#[cfg(feature = "runtime")]
|
||||
{
|
||||
::tokio_executor::spawn(fut)
|
||||
}
|
||||
#[cfg(not(feature = "runtime"))]
|
||||
{
|
||||
// If no runtime, we need an executor!
|
||||
panic!("executor must be set")
|
||||
}
|
||||
},
|
||||
Exec::Executor(ref e) => {
|
||||
let _ = e.execute(Box::new(fut))
|
||||
.map_err(|err| {
|
||||
|
||||
Reference in New Issue
Block a user