Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

[WIP] Update futures-preview to 0.3.0-alpha.16 #26

Merged
merged 2 commits into from
May 12, 2019
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
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ categories = ["asynchronous", "network-programming", "filesystem", "concurrency"
edition = "2018"

[dependencies]
futures-preview = "0.3.0-alpha.15"
futures-preview = "0.3.0-alpha.16"
runtime-attributes = { path = "runtime-attributes", version = "0.3.0-alpha.3" }
runtime-raw = { path = "runtime-raw", version = "0.3.0-alpha.2" }
runtime-native = { path = "runtime-native", version = "0.3.0-alpha.2" }

[dev-dependencies]
failure = "0.1.5"
futures01 = { package = "futures", version = "0.1" }
futures-preview = { version = "0.3.0-alpha.15", features = ["nightly", "async-await"] }
futures-preview = { version = "0.3.0-alpha.16", features = ["nightly", "async-await"] }
juliex = "0.3.0-alpha.5"
mio = "0.6.16"
rand = "0.6.5"
Expand All @@ -40,3 +40,7 @@ members = [
"runtime-raw",
"runtime-tokio",
]

[patch.crates-io]
romio = { git = "https://github.com/dbcfd/romio", branch = "futures-changes" }
juliex = { git = "https://github.com/taiki-e/juliex", branch = "await" }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ asynchronous software.
## Examples
__UDP Echo Server__
```rust
#![feature(async_await, await_macro)]
#![feature(async_await)]

use runtime::net::UdpSocket;

Expand All @@ -81,8 +81,8 @@ async fn main() -> std::io::Result<()> {
println!("Listening on {}", socket.local_addr()?);

loop {
let (recv, peer) = await!(socket.recv_from(&mut buf))?;
let sent = await!(socket.send_to(&buf[..recv], &peer))?;
let (recv, peer) = socket.recv_from(&mut buf).await?;
let sent = socket.send_to(&buf[..recv], &peer).await?;
println!("Sent {} out of {} bytes to {}", sent, recv, peer);
}
}
Expand Down
12 changes: 6 additions & 6 deletions benches/baseline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(test, async_await, await_macro)]
#![feature(test, async_await)]

extern crate test;

Expand Down Expand Up @@ -43,13 +43,13 @@ mod baseline {
let tasks = (0..300)
.map(|_| {
spawn(async move {
await!(Task { depth: 0 });
Task { depth: 0 }.await;
})
})
.collect::<Vec<_>>();

for task in tasks {
await!(task);
task.await;
}
})
});
Expand All @@ -62,7 +62,7 @@ mod baseline {
let tasks = (0..25_000).map(|_| spawn(async {})).collect::<Vec<_>>();

for task in tasks {
await!(task);
task.await;
}
})
});
Expand Down Expand Up @@ -106,7 +106,7 @@ mod baseline {
.collect::<Vec<_>>();

for task in tasks {
await!(task);
task.await;
}
})
});
Expand All @@ -121,7 +121,7 @@ mod baseline {
let (tx, rx) = futures::channel::oneshot::channel();

let fut = async move {
let t = await!(fut);
let t = fut.await;
let _ = tx.send(t);
};

Expand Down
8 changes: 4 additions & 4 deletions benches/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ macro_rules! benchmark_suite {
let tasks = (0..300)
.map(|_| {
runtime::spawn(async {
await!(Task { depth: 0 });
Task { depth: 0 }.await;
})
})
.collect::<Vec<_>>();

for task in tasks {
await!(task);
task.await;
}
}

Expand All @@ -48,7 +48,7 @@ macro_rules! benchmark_suite {
.collect::<Vec<_>>();

for task in tasks {
await!(task);
task.await;
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ macro_rules! benchmark_suite {
.collect::<Vec<_>>();

for task in tasks {
await!(task);
task.await;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion benches/native.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(test, async_await, await_macro)]
#![feature(test, async_await)]
#![warn(rust_2018_idioms)]

extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion benches/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(test, async_await, await_macro)]
#![feature(test, async_await)]
#![warn(rust_2018_idioms)]

extern crate test;
Expand Down
18 changes: 9 additions & 9 deletions examples/guessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! $ nc localhost 8080
//! ```

#![feature(async_await, await_macro)]
#![feature(async_await)]

use futures::prelude::*;
use rand::Rng;
Expand All @@ -21,14 +21,14 @@ async fn play(stream: TcpStream) -> Result<(), failure::Error> {
let (reader, writer) = &mut stream.split();
let mut buf = vec![0u8; 1024];

await!(writer.write_all(b"Guess the number!\n"))?;
writer.write_all(b"Guess the number!\n").await?;

let secret_number = rand::thread_rng().gen_range(1, 101);

loop {
await!(writer.write_all(b"Please input your guess.\n"))?;
writer.write_all(b"Please input your guess.\n").await?;

let len = await!(reader.read(&mut buf))?;
let len = reader.read(&mut buf).await?;
if len == 0 {
return Ok(());
}
Expand All @@ -41,13 +41,13 @@ async fn play(stream: TcpStream) -> Result<(), failure::Error> {
};

let msg = format!("You guessed: {}\n", guess);
await!(writer.write_all(msg.as_bytes()))?;
writer.write_all(msg.as_bytes()).await?;

match guess.cmp(&secret_number) {
Ordering::Less => await!(writer.write_all(b"Too small!\n"))?,
Ordering::Greater => await!(writer.write_all(b"Too big!\n"))?,
Ordering::Less => writer.write_all(b"Too small!\n").await?,
Ordering::Greater => writer.write_all(b"Too big!\n").await?,
Ordering::Equal => {
await!(writer.write_all(b"You win!\n"))?;
writer.write_all(b"You win!\n").await?;
break;
}
}
Expand All @@ -62,7 +62,7 @@ async fn main() -> Result<(), failure::Error> {
println!("Listening on {}", &listener.local_addr()?);

let mut incoming = listener.incoming();
while let Some(stream) = await!(incoming.next()) {
while let Some(stream) = incoming.next().await {
runtime::spawn(play(stream?));
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]

async fn say_hi() {
println!("Hello world! 🤖");
}

#[runtime::main]
async fn main() {
await!(say_hi());
say_hi().await;
}
8 changes: 4 additions & 4 deletions examples/tcp-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
//! $ cargo run --example tcp-echo
//! ```

#![feature(async_await, await_macro)]
#![feature(async_await)]

use futures::prelude::*;
use runtime::net::TcpStream;

#[runtime::main]
async fn main() -> Result<(), failure::Error> {
let mut stream = await!(TcpStream::connect("127.0.0.1:8080"))?;
let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
println!("Connected to {}", &stream.peer_addr()?);

let msg = "hello world";
println!("<- {}", msg);
await!(stream.write_all(msg.as_bytes()))?;
stream.write_all(msg.as_bytes()).await?;

let mut buf = vec![0u8; 1024];
await!(stream.read(&mut buf))?;
stream.read(&mut buf).await?;
println!("-> {}\n", String::from_utf8(buf)?);

Ok(())
Expand Down
6 changes: 3 additions & 3 deletions examples/tcp-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Run the server and connect to it with `nc 127.0.0.1 8080`.
//! The server will wait for you to enter lines of text and then echo them back.

#![feature(async_await, await_macro)]
#![feature(async_await)]

use futures::prelude::*;
use runtime::net::TcpListener;
Expand All @@ -15,13 +15,13 @@ async fn main() -> std::io::Result<()> {

// accept connections and process them in parallel
let mut incoming = listener.incoming();
while let Some(stream) = await!(incoming.next()) {
while let Some(stream) = incoming.next().await {
runtime::spawn(async move {
let stream = stream?;
println!("Accepting from: {}", stream.peer_addr()?);

let (reader, writer) = &mut stream.split();
await!(reader.copy_into(writer))?;
reader.copy_into(writer).await?;
Ok::<(), std::io::Error>(())
});
}
Expand Down
8 changes: 4 additions & 4 deletions examples/tcp-proxy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A TCP proxy server. Forwards connections from port 8081 to port 8080.

#![feature(async_await, await_macro)]
#![feature(async_await)]

use futures::prelude::*;
use futures::try_join;
Expand All @@ -13,10 +13,10 @@ async fn main() -> std::io::Result<()> {

// accept connections and process them serially
let mut incoming = listener.incoming();
while let Some(client) = await!(incoming.next()) {
while let Some(client) = incoming.next().await {
let handle = runtime::spawn(async move {
let client = client?;
let server = await!(TcpStream::connect("127.0.0.1:8080"))?;
let server = TcpStream::connect("127.0.0.1:8080").await?;
println!(
"Proxying {} to {}",
client.peer_addr()?,
Expand All @@ -32,7 +32,7 @@ async fn main() -> std::io::Result<()> {
Ok::<(), std::io::Error>(())
});

await!(handle)?;
handle.await?;
}
Ok(())
}
6 changes: 3 additions & 3 deletions examples/udp-client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]

//! UDP client.
//!
Expand All @@ -16,10 +16,10 @@ async fn main() -> std::io::Result<()> {

let msg = "hello world";
println!("<- {}", msg);
await!(socket.send_to(msg.as_bytes(), "127.0.0.1:8080"))?;
socket.send_to(msg.as_bytes(), "127.0.0.1:8080").await?;

let mut buf = vec![0u8; 1024];
await!(socket.recv_from(&mut buf))?;
socket.recv_from(&mut buf).await?;
println!("-> {}\n", String::from_utf8_lossy(&mut buf));

Ok(())
Expand Down
6 changes: 3 additions & 3 deletions examples/udp-echo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]

//! UDP echo server.
//!
Expand All @@ -17,8 +17,8 @@ async fn main() -> std::io::Result<()> {
println!("Listening on {}", socket.local_addr()?);

loop {
let (recv, peer) = await!(socket.recv_from(&mut buf))?;
let sent = await!(socket.send_to(&buf[..recv], &peer))?;
let (recv, peer) = socket.recv_from(&mut buf).await?;
let sent = socket.send_to(&buf[..recv], &peer).await?;
println!("Sent {} out of {} bytes to {}", sent, recv, peer);
}
}
8 changes: 4 additions & 4 deletions runtime-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![forbid(unsafe_code, future_incompatible, rust_2018_idioms)]
#![deny(missing_debug_implementations, nonstandard_style)]
#![feature(async_await, await_macro)]
#![feature(async_await)]
#![recursion_limit = "512"]

extern crate proc_macro;
Expand Down Expand Up @@ -62,7 +62,7 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream {
}

runtime::raw::enter(#rt, async {
await!(main())
main().await
})
}

Expand Down Expand Up @@ -120,13 +120,13 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream {
/// # Examples
///
/// ```ignore
/// #![feature(async_await, await_macro, test)]
/// #![feature(async_await, test)]
///
/// extern crate test;
///
/// #[runtime::test]
/// async fn spawn_and_await() {
/// await!(runtime::spawn(async {}));
/// runtime::spawn(async {}).await;
/// }
/// ```
#[proc_macro_attribute]
Expand Down
2 changes: 1 addition & 1 deletion runtime-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = ["asynchronous", "network-programming", "filesystem", "concurrency"
edition = "2018"

[dependencies]
futures-preview = { version = "0.3.0-alpha.15", features = ["compat"] }
futures-preview = { version = "0.3.0-alpha.16", features = ["compat"] }
runtime-raw = { path = "../runtime-raw", version = "0.3.0-alpha.2" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion runtime-native/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A cross-platform asynchronous [Runtime](https://github.com/rustasync/runtime). See the [Runtime
//! documentation](https://docs.rs/runtime) for more details.

#![feature(async_await, await_macro)]
#![feature(async_await)]
#![deny(unsafe_code)]
#![warn(
missing_debug_implementations,
Expand Down
2 changes: 1 addition & 1 deletion runtime-raw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ categories = ["asynchronous", "network-programming", "filesystem", "concurrency"
edition = "2018"

[dependencies]
futures-preview = "0.3.0-alpha.15"
futures-preview = "0.3.0-alpha.16"
Loading