Skip to content

Commit

Permalink
Switch back to futures from crates.io (#113)
Browse files Browse the repository at this point in the history
Doing so requires copying the `current_thread` executor from GitHub into
the repo.
  • Loading branch information
carllerche authored Feb 6, 2018
1 parent 567887c commit f0ea9d6
Show file tree
Hide file tree
Showing 31 changed files with 1,313 additions and 70 deletions.
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,3 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
time = "0.1"

[patch.crates-io]
futures = { git = "https://github.com/rust-lang-nursery/futures-rs", branch = "tokio-reform" }
mio = { git = "https://github.com/carllerche/mio" }
4 changes: 2 additions & 2 deletions examples/chat-combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::io::{Error, ErrorKind, BufReader};
use std::sync::{Arc, Mutex};

use futures::Future;
use futures::future::{self, Executor};
use futures::future::Executor;
use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio::net::TcpListener;
Expand Down Expand Up @@ -134,5 +134,5 @@ fn main() {
});

// execute server
future::blocking(srv).wait().unwrap();
srv.wait().unwrap();
}
2 changes: 1 addition & 1 deletion examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ extern crate tokio;
extern crate tokio_io;
extern crate bytes;

use tokio::executor::current_thread;
use tokio::net::{TcpListener, TcpStream};
use tokio_io::{AsyncRead};
use futures::prelude::*;
use futures::current_thread;
use futures::sync::mpsc;
use futures::future::{self, Either};
use bytes::{BytesMut, Bytes, BufMut};
Expand Down
4 changes: 2 additions & 2 deletions examples/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::env;
use std::net::SocketAddr;

use futures::{Future, Stream, Poll};
use futures::future::{self, Executor};
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::{TcpListener, TcpStream};
use tokio_io::{AsyncRead, AsyncWrite};
Expand Down Expand Up @@ -62,7 +62,7 @@ fn main() {
Ok(())
});

future::blocking(server).wait().unwrap();
server.wait().unwrap();
}

/// The main workhorse of this example. This'll compress all data read from
Expand Down
8 changes: 4 additions & 4 deletions examples/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::net::SocketAddr;
use std::thread;

use futures::sync::mpsc;
use futures::{future, Sink, Stream};
use futures::{Future, Sink, Stream};
use futures_cpupool::CpuPool;

fn main() {
Expand Down Expand Up @@ -71,9 +71,9 @@ fn main() {
// loop. In this case, though, we know it's ok as the event loop isn't
// otherwise running anything useful.
let mut out = io::stdout();
future::blocking(stdout.for_each(|chunk| {
stdout.for_each(|chunk| {
out.write_all(&chunk)
})).wait().unwrap();
}).wait().unwrap();
}

mod tcp {
Expand Down Expand Up @@ -244,7 +244,7 @@ fn read_stdin(mut tx: mpsc::Sender<Vec<u8>>) {
Ok(n) => n,
};
buf.truncate(n);
tx = match future::blocking(tx.send(buf)).wait() {
tx = match tx.send(buf).wait() {
Ok(tx) => tx,
Err(_) => break,
};
Expand Down
6 changes: 3 additions & 3 deletions examples/echo-threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::net::SocketAddr;
use std::thread;

use futures::prelude::*;
use futures::future::{self, Executor};
use futures::future::Executor;
use futures::sync::mpsc;
use futures_cpupool::CpuPool;
use tokio_io::AsyncRead;
Expand Down Expand Up @@ -61,7 +61,7 @@ fn main() {
next = (next + 1) % channels.len();
Ok(())
});
future::blocking(srv).wait().unwrap();
srv.wait().unwrap();
}

fn worker(rx: mpsc::UnboundedReceiver<TcpStream>) {
Expand All @@ -88,5 +88,5 @@ fn worker(rx: mpsc::UnboundedReceiver<TcpStream>) {

Ok(())
});
future::blocking(done).wait().unwrap();
done.wait().unwrap();
}
6 changes: 3 additions & 3 deletions examples/echo-udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate tokio_io;
use std::{env, io};
use std::net::SocketAddr;

use futures::{future, Future, Poll};
use futures::{Future, Poll};
use tokio::net::UdpSocket;

struct Server {
Expand Down Expand Up @@ -58,9 +58,9 @@ fn main() {

// Next we'll create a future to spawn (the one we defined above) and then
// we'll block our current thread waiting on the result of the future
future::blocking(Server {
Server {
socket: socket,
buf: vec![0; 1024],
to_send: None,
}).wait().unwrap();
}.wait().unwrap();
}
4 changes: 2 additions & 2 deletions examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::env;
use std::net::SocketAddr;

use futures::Future;
use futures::future::{self, Executor};
use futures::future::Executor;
use futures::stream::Stream;
use futures_cpupool::CpuPool;
use tokio_io::AsyncRead;
Expand Down Expand Up @@ -114,5 +114,5 @@ fn main() {
// And finally now that we've define what our server is, we run it! Here we
// just need to execute the future we've created and wait for it to complete
// using the standard methods in the `futures` crate.
future::blocking(done).wait().unwrap();
done.wait().unwrap();
}
3 changes: 1 addition & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extern crate tokio_io;
use std::env;
use std::net::SocketAddr;

use futures::future;
use futures::prelude::*;
use tokio::net::TcpListener;

Expand All @@ -41,5 +40,5 @@ fn main() {
Ok(())
});

future::blocking(server).wait().unwrap();
server.wait().unwrap();
}
3 changes: 2 additions & 1 deletion examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ extern crate tokio;
extern crate tokio_io;
extern crate futures;

use tokio::executor::current_thread;
use tokio::net::TcpListener;
use tokio_io::io;
use futures::{current_thread, Future, Stream};
use futures::{Future, Stream};

pub fn main() {
let addr = "127.0.0.1:6142".parse().unwrap();
Expand Down
5 changes: 3 additions & 2 deletions examples/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::io::{self, Read, Write};

use futures::stream::Stream;
use futures::{Future, Poll};
use futures::future::{self, Executor};
use futures::future::{Executor};
use futures_cpupool::CpuPool;
use tokio::net::{TcpListener, TcpStream};
use tokio_io::{AsyncRead, AsyncWrite};
Expand Down Expand Up @@ -92,7 +92,8 @@ fn main() {

Ok(())
});
future::blocking(done).wait().unwrap();

done.wait().unwrap();
}

// This is a custom type used to have a custom implementation of the
Expand Down
4 changes: 2 additions & 2 deletions examples/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::iter;
use std::net::SocketAddr;

use futures::Future;
use futures::future::{self, Executor};
use futures::future::Executor;
use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio_io::IoFuture;
Expand All @@ -46,7 +46,7 @@ fn main() {
pool.execute(write(socket).or_else(|_| Ok(()))).unwrap();
Ok(())
});
future::blocking(server).wait().unwrap();
server.wait().unwrap();
}

fn write(socket: TcpStream) -> IoFuture<()> {
Expand Down
4 changes: 2 additions & 2 deletions examples/tinydb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use std::net::SocketAddr;
use std::sync::{Arc, Mutex};

use futures::prelude::*;
use futures::future::{self, Executor};
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::TcpListener;
use tokio_io::AsyncRead;
Expand Down Expand Up @@ -160,7 +160,7 @@ fn main() {
Ok(())
});

future::blocking(done).wait().unwrap();
done.wait().unwrap();
}

impl Request {
Expand Down
2 changes: 1 addition & 1 deletion examples/tinyhttp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
})).unwrap();
Ok(())
});
future::blocking(done).wait().unwrap();
done.wait().unwrap();
}

/// "Server logic" is implemented in this function.
Expand Down
4 changes: 2 additions & 2 deletions examples/udp-codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::io;
use std::net::SocketAddr;

use futures::{Future, Stream, Sink};
use futures::future::{self, Executor};
use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::{UdpSocket, UdpCodec};

Expand Down Expand Up @@ -76,5 +76,5 @@ fn main() {

// Spawn the sender of pongs and then wait for our pinger to finish.
pool.execute(b.then(|_| Ok(()))).unwrap();
drop(future::blocking(a).wait());
drop(a.wait());
}
Loading

0 comments on commit f0ea9d6

Please sign in to comment.