summaryrefslogtreecommitdiffstats
path: root/third_party/rust/futures-0.1.29/tests/recurse.rs
blob: 4eb024ac95446e0e574c3994f103db808cdc04c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
extern crate futures;

use std::sync::mpsc::channel;

use futures::future::ok;
use futures::prelude::*;

#[test]
fn lots() {
    fn doit(n: usize) -> Box<Future<Item=(), Error=()> + Send> {
        if n == 0 {
            Box::new(ok(()))
        } else {
            Box::new(ok(n - 1).and_then(doit))
        }
    }

    let (tx, rx) = channel();
    ::std::thread::spawn(|| {
        doit(1_000).map(move |_| tx.send(()).unwrap()).wait()
    });
    rx.recv().unwrap();
}