Remove dead futures2 code. (#538)

The futures 0.2 crate is not intended for widespread usage. Also, the
futures team is exploring the compat shim route.

If futures 0.3 support is added to Tokio 0.1, then a different
integration route will be explored, making the current code unhelpful.
This commit is contained in:
Carl Lerche
2018-08-09 21:56:53 -07:00
committed by GitHub
parent 96b556fbff
commit d91c775f36
31 changed files with 67 additions and 1380 deletions
-9
View File
@@ -3,9 +3,6 @@ use std::cell::Cell;
use std::error::Error;
use std::fmt;
#[cfg(feature = "unstable-futures")]
use futures2;
thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
/// Represents an executor context.
@@ -14,9 +11,6 @@ thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
pub struct Enter {
on_exit: Vec<Box<Callback>>,
permanent: bool,
#[cfg(feature = "unstable-futures")]
_enter2: futures2::executor::Enter,
}
/// An error returned by `enter` if an execution scope has already been
@@ -66,9 +60,6 @@ pub fn enter() -> Result<Enter, EnterError> {
Ok(Enter {
on_exit: Vec::new(),
permanent: false,
#[cfg(feature = "unstable-futures")]
_enter2: futures2::executor::enter().unwrap(),
})
}
})
+1 -21
View File
@@ -4,9 +4,6 @@ use futures::Future;
use std::cell::Cell;
#[cfg(feature = "unstable-futures")]
use futures2;
/// Executes futures on the default executor for the current execution context.
///
/// `DefaultExecutor` implements `Executor` and can be used to spawn futures
@@ -65,7 +62,7 @@ enum State {
Ready(*mut Executor),
// default executor is currently active (used to detect recursive calls)
Active
}
}
/// Thread-local tracking the current executor
thread_local!(static EXECUTOR: Cell<State> = Cell::new(State::Empty));
@@ -80,14 +77,6 @@ impl super::Executor for DefaultExecutor {
.unwrap_or_else(|| Err(SpawnError::shutdown()))
}
#[cfg(feature = "unstable-futures")]
fn spawn2(&mut self, future: Box<futures2::Future<Item = (), Error = futures2::Never> + Send>)
-> Result<(), futures2::executor::SpawnError>
{
DefaultExecutor::with_current(|executor| executor.spawn2(future))
.unwrap_or_else(|| Err(futures2::executor::SpawnError::shutdown()))
}
fn status(&self) -> Result<(), SpawnError> {
DefaultExecutor::with_current(|executor| executor.status())
.unwrap_or_else(|| Err(SpawnError::shutdown()))
@@ -142,15 +131,6 @@ pub fn spawn<T>(future: T)
.unwrap()
}
/// Like `spawn` but compatible with futures 0.2
#[cfg(feature = "unstable-futures")]
pub fn spawn2<T>(future: T)
where T: futures2::Future<Item = (), Error = futures2::Never> + Send + 'static,
{
DefaultExecutor::current().spawn2(Box::new(future))
.unwrap()
}
/// Set the default executor for the duration of the closure
///
/// # Panics
-18
View File
@@ -37,9 +37,6 @@
extern crate futures;
#[cfg(feature = "unstable-futures")]
extern crate futures2;
mod enter;
mod global;
pub mod park;
@@ -47,9 +44,6 @@ pub mod park;
pub use enter::{enter, Enter, EnterError};
pub use global::{spawn, with_default, DefaultExecutor};
#[cfg(feature = "unstable-futures")]
pub use global::spawn2;
use futures::Future;
use std::error::Error;
@@ -142,11 +136,6 @@ pub trait Executor {
fn spawn(&mut self, future: Box<Future<Item = (), Error = ()> + Send>)
-> Result<(), SpawnError>;
/// Like `spawn`, but compatible with futures 0.2
#[cfg(feature = "unstable-futures")]
fn spawn2(&mut self, future: Box<futures2::Future<Item = (), Error = futures2::Never> + Send>)
-> Result<(), futures2::executor::SpawnError>;
/// Provides a best effort **hint** to whether or not `spawn` will succeed.
///
/// This function may return both false positives **and** false negatives.
@@ -194,13 +183,6 @@ impl<E: Executor + ?Sized> Executor for Box<E> {
(**self).spawn(future)
}
#[cfg(feature = "unstable-futures")]
fn spawn2(&mut self, future: Box<futures2::Future<Item = (), Error = futures2::Never> + Send>)
-> Result<(), futures2::executor::SpawnError>
{
(**self).spawn2(future)
}
fn status(&self) -> Result<(), SpawnError> {
(**self).status()
}