Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ if_std! {
pub use self::join_all::JoinAll as Collect;

/// A type alias for `Box<Future + Send>`
#[doc(hidden)]
#[deprecated(note = "removed without replacement, recommended to use a \
local extension trait or function if needed, more \
details in #228")]
pub type BoxFuture<T, E> = ::std::boxed::Box<Future<Item = T, Error = E> + Send>;

impl<F: ?Sized + Future> Future for ::std::boxed::Box<F> {
Expand Down Expand Up @@ -313,6 +317,11 @@ pub trait Future {
/// let a: BoxFuture<i32, i32> = result(Ok(1)).boxed();
/// ```
#[cfg(feature = "use_std")]
#[doc(hidden)]
#[deprecated(note = "removed without replacement, recommended to use a \
local extension trait or function if needed, more \
details in #228")]
#[allow(deprecated)]
fn boxed(self) -> BoxFuture<Self::Item, Self::Error>
where Self: Sized + Send + 'static
{
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ if_std! {
#[doc(hidden)]
#[deprecated(since = "0.1.4", note = "import through the future module instead")]
#[cfg(feature = "with-deprecated")]
#[allow(deprecated)]
pub use future::{BoxFuture, collect, select_all, select_ok};

#[doc(hidden)]
Expand Down
9 changes: 9 additions & 0 deletions src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ if_std! {
pub use self::channel::{channel, Sender, Receiver, FutureSender, SendError};

/// A type alias for `Box<Stream + Send>`
#[doc(hidden)]
#[deprecated(note = "removed without replacement, recommended to use a \
local extension trait or function if needed, more \
details in #228")]
pub type BoxStream<T, E> = ::std::boxed::Box<Stream<Item = T, Error = E> + Send>;

impl<S: ?Sized + Stream> Stream for ::std::boxed::Box<S> {
Expand Down Expand Up @@ -251,6 +255,11 @@ pub trait Stream {
/// let a: BoxStream<i32, ()> = rx.boxed();
/// ```
#[cfg(feature = "use_std")]
#[doc(hidden)]
#[deprecated(note = "removed without replacement, recommended to use a \
local extension trait or function if needed, more \
details in #228")]
#[allow(deprecated)]
fn boxed(self) -> BoxStream<Self::Item, Self::Error>
where Self: Sized + Send + 'static,
{
Expand Down
5 changes: 2 additions & 3 deletions src/task_impl/std/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;

use {Future, Stream, Sink, Poll, Async, StartSend, AsyncSink};
use future::BoxFuture;
use super::core;
use super::{BorrowedTask, NotifyHandle, Spawn, spawn, Notify, UnsafeNotify};

Expand Down Expand Up @@ -276,7 +275,7 @@ impl<F: Future> Spawn<F> {
// `Spawn<BoxFuture<(), ()>>` so we wouldn't have to box here and
// it'd be more explicit, but unfortunately that currently has a
// link error on nightly: rust-lang/rust#36155
spawn: spawn(self.into_inner().boxed()),
spawn: spawn(Box::new(self.into_inner())),
inner: Arc::new(RunInner {
exec: exec,
mutex: UnparkMutex::new()
Expand Down Expand Up @@ -404,7 +403,7 @@ pub trait Executor: Send + Sync + 'static {
/// Units of work submitted to an `Executor`, currently only created
/// internally.
pub struct Run {
spawn: Spawn<BoxFuture<(), ()>>,
spawn: Spawn<Box<Future<Item = (), Error = ()> + Send>>,
inner: Arc<RunInner>,
}

Expand Down
6 changes: 3 additions & 3 deletions tests/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ fn sequence() {
fn send(n: u32, sender: mpsc::Sender<u32>)
-> Box<Future<Item=(), Error=()> + Send> {
if n == 0 {
return result(Ok(())).boxed()
return Box::new(result(Ok(())))
}
sender.send(n).map_err(|_| ()).and_then(move |sender| {
Box::new(sender.send(n).map_err(|_| ()).and_then(move |sender| {
send(n - 1, sender)
}).boxed()
}))
}
}

Expand Down
9 changes: 6 additions & 3 deletions tests/futures_ordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ fn works_2() {
let (b_tx, b_rx) = oneshot::channel::<u32>();
let (c_tx, c_rx) = oneshot::channel::<u32>();

let stream = futures_ordered(vec![a_rx.boxed(), b_rx.join(c_rx).map(|(a, b)| a + b).boxed()]);
let stream = futures_ordered(vec![
Box::new(a_rx) as Box<Future<Item = _, Error = _>>,
Box::new(b_rx.join(c_rx).map(|(a, b)| a + b)),
]);

let mut spawn = futures::executor::spawn(stream);
a_tx.send(33).unwrap();
Expand All @@ -52,8 +55,8 @@ fn queue_never_unblocked() {
let (c_tx, c_rx) = oneshot::channel::<Box<Any+Send>>();

let stream = futures_ordered(vec![
a_rx.boxed(),
b_rx.select(c_rx).then(|res| Ok(Box::new(res) as Box<Any+Send>)).boxed(),
Box::new(a_rx) as Box<Future<Item = _, Error = _>>,
Box::new(b_rx.select(c_rx).then(|res| Ok(Box::new(res) as Box<Any+Send>))),
]);

let mut spawn = futures::executor::spawn(stream);
Expand Down
9 changes: 6 additions & 3 deletions tests/futures_unordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ fn works_2() {
let (b_tx, b_rx) = oneshot::channel::<u32>();
let (c_tx, c_rx) = oneshot::channel::<u32>();

let stream = futures_unordered(vec![a_rx.boxed(), b_rx.join(c_rx).map(|(a, b)| a + b).boxed()]);
let stream = futures_unordered(vec![
Box::new(a_rx) as Box<Future<Item = _, Error = _>>,
Box::new(b_rx.join(c_rx).map(|(a, b)| a + b)),
]);

let mut spawn = futures::executor::spawn(stream);
a_tx.send(33).unwrap();
Expand All @@ -50,8 +53,8 @@ fn finished_future_ok() {
let (c_tx, c_rx) = oneshot::channel::<Box<Any+Send>>();

let stream = futures_unordered(vec![
a_rx.boxed(),
b_rx.select(c_rx).then(|res| Ok(Box::new(res) as Box<Any+Send>)).boxed(),
Box::new(a_rx) as Box<Future<Item = _, Error = _>>,
Box::new(b_rx.select(c_rx).then(|res| Ok(Box::new(res) as Box<Any+Send>))),
]);

let mut spawn = futures::executor::spawn(stream);
Expand Down
2 changes: 1 addition & 1 deletion tests/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn stress_drop_sender() {
.and_then(|tx| tx.send(Ok(2)))
.and_then(|tx| tx.send(Ok(3)))
.forget();
rx.then(|r| r.unwrap()).boxed()
Box::new(rx.then(|r| r.unwrap()))
}

for _ in 0..10000 {
Expand Down
4 changes: 2 additions & 2 deletions tests/recurse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use futures::future::{ok, Future};
fn lots() {
fn doit(n: usize) -> Box<Future<Item=(), Error=()> + Send> {
if n == 0 {
ok(()).boxed()
Box::new(ok(()))
} else {
ok(n - 1).and_then(doit).boxed()
Box::new(ok(n - 1).and_then(doit))
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/select_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use futures::future::*;
#[test]
fn smoke() {
let v = vec![
ok(1).boxed(),
err(2).boxed(),
ok(3).boxed(),
ok(1),
err(2),
ok(3),
];

let (i, idx, v) = select_all(v).wait().ok().unwrap();
Expand Down
14 changes: 7 additions & 7 deletions tests/select_ok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use futures::future::*;
#[test]
fn ignore_err() {
let v = vec![
err(1).boxed(),
err(2).boxed(),
ok(3).boxed(),
ok(4).boxed(),
err(1),
err(2),
ok(3),
ok(4),
];

let (i, v) = select_ok(v).wait().ok().unwrap();
Expand All @@ -25,9 +25,9 @@ fn ignore_err() {
#[test]
fn last_err() {
let v = vec![
ok(1).boxed(),
err(2).boxed(),
err(3).boxed(),
ok(1),
err(2),
err(3),
];

let (i, v) = select_ok(v).wait().ok().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ fn mpsc_blocking_start_send() {
// until a oneshot is completed
fn with_flush() {
let (tx, rx) = oneshot::channel();
let mut block = rx.boxed();
let mut block = Box::new(rx) as Box<Future<Item = _, Error = _>>;
let mut sink = Vec::new().with(|elem| {
mem::replace(&mut block, ok(()).boxed())
mem::replace(&mut block, Box::new(ok(())))
.map(move |_| elem + 1).map_err(|_| -> () { panic!() })
});

Expand Down
28 changes: 14 additions & 14 deletions tests/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ extern crate futures;
use futures::{Async, Future, Poll, Sink, Stream};
use futures::executor;
use futures::future::{err, ok};
use futures::stream::{empty, iter, poll_fn, BoxStream, Peekable};
use futures::stream::{empty, iter, poll_fn, Peekable};
use futures::sync::oneshot;
use futures::sync::mpsc;

mod support;
use support::*;


fn list() -> BoxStream<i32, u32> {
fn list() -> Box<Stream<Item=i32, Error=u32> + Send> {
let (tx, rx) = mpsc::channel(1);
tx.send(Ok(1))
.and_then(|tx| tx.send(Ok(2)))
.and_then(|tx| tx.send(Ok(3)))
.forget();
rx.then(|r| r.unwrap()).boxed()
Box::new(rx.then(|r| r.unwrap()))
}

fn err_list() -> BoxStream<i32, u32> {
fn err_list() -> Box<Stream<Item=i32, Error=u32> + Send> {
let (tx, rx) = mpsc::channel(1);
tx.send(Ok(1))
.and_then(|tx| tx.send(Ok(2)))
.and_then(|tx| tx.send(Err(3)))
.forget();
rx.then(|r| r.unwrap()).boxed()
Box::new(rx.then(|r| r.unwrap()))
}

#[test]
Expand Down Expand Up @@ -173,8 +173,8 @@ fn buffered() {
let (a, b) = oneshot::channel::<u32>();
let (c, d) = oneshot::channel::<u32>();

tx.send(b.map_err(|_| ()).boxed())
.and_then(|tx| tx.send(d.map_err(|_| ()).boxed()))
tx.send(Box::new(b.map_err(|_| ())) as Box<Future<Item = _, Error = _> + Send>)
.and_then(|tx| tx.send(Box::new(d.map_err(|_| ()))))
.forget();

let mut rx = rx.buffered(2);
Expand All @@ -191,8 +191,8 @@ fn buffered() {
let (a, b) = oneshot::channel::<u32>();
let (c, d) = oneshot::channel::<u32>();

tx.send(b.map_err(|_| ()).boxed())
.and_then(|tx| tx.send(d.map_err(|_| ()).boxed()))
tx.send(Box::new(b.map_err(|_| ())) as Box<Future<Item = _, Error = _> + Send>)
.and_then(|tx| tx.send(Box::new(d.map_err(|_| ()))))
.forget();

let mut rx = rx.buffered(1);
Expand All @@ -212,8 +212,8 @@ fn unordered() {
let (a, b) = oneshot::channel::<u32>();
let (c, d) = oneshot::channel::<u32>();

tx.send(b.map_err(|_| ()).boxed())
.and_then(|tx| tx.send(d.map_err(|_| ()).boxed()))
tx.send(Box::new(b.map_err(|_| ())) as Box<Future<Item = _, Error = _> + Send>)
.and_then(|tx| tx.send(Box::new(d.map_err(|_| ()))))
.forget();

let mut rx = rx.buffer_unordered(2);
Expand All @@ -229,8 +229,8 @@ fn unordered() {
let (a, b) = oneshot::channel::<u32>();
let (c, d) = oneshot::channel::<u32>();

tx.send(b.map_err(|_| ()).boxed())
.and_then(|tx| tx.send(d.map_err(|_| ()).boxed()))
tx.send(Box::new(b.map_err(|_| ())) as Box<Future<Item = _, Error = _> + Send>)
.and_then(|tx| tx.send(Box::new(d.map_err(|_| ()))))
.forget();

// We don't even get to see `c` until `a` completes.
Expand Down Expand Up @@ -261,7 +261,7 @@ fn zip() {
#[test]
fn peek() {
struct Peek {
inner: Peekable<BoxStream<i32, u32>>
inner: Peekable<Box<Stream<Item = i32, Error =u32> + Send>>
}

impl Future for Peek {
Expand Down